Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Converting a string to date


Hi

i have a string of the format YYYY-MM-DD and i want to convert it to a date of the same format, can anyone help???? I've tried the dateFormat and simpledateformat but cant get the format i want.

Thanks
Suzy
0
fyness
Asked:
fyness
  • 2
1 Solution
 
kiranhkCommented:
hi
check out this

http://www.idevelopment.info/data/Programming/java/PROGRAMMING_Java_Programming.shtml

In that check out Date / Time Example

Kiran
0
 
fynessAuthor Commented:
Thanks for the reply there is still no where that i can see how to parse a string to YYYY-MM-DD date format. It will let me do it for dd-mm-yy but thats it
0
 
kiranhkCommented:
n the Date/Time example didnt you check out the following code

    prt("PARSE STRING TO DATE");
     prt("=================================================================");
     Date   newDate;
     String inputDate = "1994-02-14";
     SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
     System.out.print("  " + inputDate + " parses as ");
     try {
         newDate = formatter.parse(inputDate);
         prt(newDate + ".");
     } catch (ParseException e) {
         prt("Unparseable using " + formatter + ".");
     }    




Kiran
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now