Solved

Converting a string to date

Posted on 2004-10-11
4
197 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
  • 2
4 Comments
 
LVL 4

Expert Comment

by:JK2429
Comment Utility
0
 
LVL 8

Expert Comment

by:kiranhk
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This video teaches viewers about errors in exception handling.

763 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now