Results 1 to 3 of 3

Thread: Convert date format - RESOLVED!!

  1. #1

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Convert date format - RESOLVED!!

    I have a date that looks like this:
    Code:
    19721101
    and I need it to be like this:
    Code:
    01-Nov-1972
    How can I convert that?
    Last edited by rockies1; Jul 1st, 2003 at 03:24 PM.
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Code:
     import java.util.Date;
     import java.text.DateFormat; 
    
      public class Z{
       public static void main(String[] args){
    
        Date d = new Date(19721101);  
        DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
    
        System.out.println(df.format(d)); 
    
       }
      }

  3. #3

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375
    Before I had a chance to try this one, someone gave me this one:
    Code:
    	public static String oracleDatePrep(java.util.Date dateIn) 
    	{
    		SimpleDateFormat oracleDateFormatter = new SimpleDateFormat("dd-MMM-yyyy");
    		String returnVal = null;
    		if (dateIn != null) 
    		{
    			returnVal =  oracleDateFormatter.format(dateIn);
    		}
    		return returnVal;
    	}//End oraclePrep
    	
    	public static java.util.Date parseToDate(String dateString) 
    	{
    		if (dateString == null) 
    		{
    			return null;
    		}
    		java.util.Date returnDate = null;
    		DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
    		formatter.setLenient(false);
    		if (dateString.length() != 0) 
    		{
    			try 
    			{
    				returnDate = formatter.parse(dateString);
    			}
    			catch (ParseException pe) 
    			{
    				
    			}
    		}
    		return returnDate;
    	}//End parseToDate
    that I call like
    Code:
    oracleDatePrep(parseToDate("20030701"))
    Thanks for your suggestions and help in the other threads!
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width