Solved

Converting a string to date

Posted on 2004-10-11
4
202 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

729 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