Solved

Converting a string to date

Posted on 2004-10-11
4
203 Views
Last Modified: 2012-05-05

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
Comment
Question by:fyness
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:kiranhk
ID: 12278408
hi
check out this

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

In that check out Date / Time Example

Kiran
0
 

Author Comment

by:fyness
ID: 12278535
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
 
LVL 8

Accepted Solution

by:
kiranhk earned 125 total points
ID: 12278824
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question