DateFormat parse() method

C

chirs

Hi,

Could you show me how to use DateFormat parse() method to parse a date
"January 1, 2004". A small example is all I need.

Thank you very much.

Chris.
 
B

Bryce (Work)

What I want is not to format a date into "MMMMMMM dd, yyyy". The
"input" is a string
such as "January 1, 2004" or "July 12, 2004", I need a Date object as
an "output". I looked at the link, but I could not find an example of
doing this. Thank you.

You didn't look hard enough. hint, look for the "parse" function of
SimpleDateFormat.
 
B

Bryce (Work)

What I want is not to format a date into "MMMMMMM dd, yyyy". The
"input" is a string
such as "January 1, 2004" or "July 12, 2004", I need a Date object as
an "output". I looked at the link, but I could not find an example of
doing this. Thank you.

awww hell... I'll just tell you.

String dateString = "January 1, 2004";
String dateFormatString = "MMMMMMM dd, yyyy";

SimpleDateFormat format = new SimpleDateFormat(dateFormatString);

Date newDate = format.parse(dateString);
 
Joined
Mar 6, 2007
Messages
1
Reaction score
0
DateFormat eg.

Here is a simple eg:

Code:
DateFormat df = new SimpleDateFormat("YYYY-MM-DDThh:mm:ss.sTZD");
String sDate = df.format(date);
Date newDate = df.parse(sDate);

but i have a problem here, newDate again not in the format passed.

Thanks
Asim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top