Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   DateFormat parse() method (http://www.velocityreviews.com/forums/t132276-dateformat-parse-method.html)

chirs 04-05-2004 07:46 PM

DateFormat parse() method
 
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.

P.Hill 04-06-2004 04:40 AM

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


See lots of listed under "Examples" at:

http://java.sun.com/j2se/1.4.2/docs/...ateFormat.html

But how about "MMMMMMM dd, yyyy"?

-Paul


chirs 04-06-2004 06:07 PM

Re: DateFormat parse() method
 
"P.Hill" <goodhill@xmission.com> wrote in message news:<c4tcbt$eb3$1@terabinaries.xmission.com>...
> chirs wrote:
> > Could you show me how to use DateFormat parse() method to parse a date
> > "January 1, 2004". A small example is all I need.

>
> See lots of listed under "Examples" at:
>
> http://java.sun.com/j2se/1.4.2/docs/...ateFormat.html
>
> But how about "MMMMMMM dd, yyyy"?
>
> -Paul


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.

Bryce (Work) 04-06-2004 08:53 PM

Re: DateFormat parse() method
 
On 6 Apr 2004 11:07:51 -0700, yma@kicon.com (chirs) wrote:

>"P.Hill" <goodhill@xmission.com> wrote in message news:<c4tcbt$eb3$1@terabinaries.xmission.com>...
>> chirs wrote:
>> > Could you show me how to use DateFormat parse() method to parse a date
>> > "January 1, 2004". A small example is all I need.

>>
>> See lots of listed under "Examples" at:
>>
>> http://java.sun.com/j2se/1.4.2/docs/...ateFormat.html
>>
>> But how about "MMMMMMM dd, yyyy"?
>>
>> -Paul

>
>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.

--
now with more cowbell

Bryce (Work) 04-06-2004 08:59 PM

Re: DateFormat parse() method
 
On 6 Apr 2004 11:07:51 -0700, yma@kicon.com (chirs) wrote:

>"P.Hill" <goodhill@xmission.com> wrote in message news:<c4tcbt$eb3$1@terabinaries.xmission.com>...
>> chirs wrote:
>> > Could you show me how to use DateFormat parse() method to parse a date
>> > "January 1, 2004". A small example is all I need.

>>
>> See lots of listed under "Examples" at:
>>
>> http://java.sun.com/j2se/1.4.2/docs/...ateFormat.html
>>
>> But how about "MMMMMMM dd, yyyy"?
>>
>> -Paul

>
>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);

--
now with more cowbell

asimali2002 03-06-2007 07:12 AM

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


All times are GMT. The time now is 01:10 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.