Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    String to date format

    hi,
    Any one say how to convert string date to date format,
    below format of my string
    ex:
    21:32:05 Feb 02, 2011 PST convert to YYYY-MM-DD hh:mm:ss

  • #2
    New Coder
    Join Date
    Jan 2011
    Location
    India
    Posts
    31
    Thanks
    0
    Thanked 4 Times in 4 Posts
    The output will be based on the local time.

    The following code will do the stuffs for you

    PHP Code:
    String st "21:32:05 Feb 02, 2011 PST";
            
            
    String dateFormat "hh:mm:ss MMM dd, yyyy z";
            
    DateFormat format = new SimpleDateFormat(dateFormat);
            
    Date d format.parse(st);
            
    DateFormat outformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            
    System.out.println(outformat.format(d)); 

  • Users who have thanked sandeep.e for this post:

    rpkaran (02-04-2011)

  • #3
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts
    hi
    thanks.
    for your reply...


  •  

    Posting Permissions

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