Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Converting a string to date

Posted on 2004-10-11
4
Medium Priority
?
205 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.
Suggested Courses

718 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