Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help in using Date Format

Status
Not open for further replies.

AnthonyGeorge

Technical User
Jun 3, 2004
46
0
0
GB
have a method that will take in a string and convert it into a Date using DateFormat.

The problem is that I am not sure what the format the string should take.

I used the date : "15-Jul-1999" which through up a java.text.ParseException: Unparseable date: "15-Jul-1999"
All I need is the day month and year not the time.

Thanks for any help, if there is docs that explain this can you send me the link.

Tony

public void setMaturityDate(String date)
{
DateFormat df = DateFormat.getDateInstance();
try
{
this.maturityDate = df.parse(date);
}
catch(ParseException e)
{
System.out.println("Error "+e);
}
}
 
You should set the right format for DateFormat and then parse your date.

---------------------------------------------
Yes, the world is full of strange people.
 
Use ISO-8601 format. Everything understands that, plus when displaying dates, it naturally sorts.

YYYY-MM-DD

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top