Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert date in different timezones into default timezone, getting Exception in thread "main" java.text.ParseException:

2 views
Skip to first unread message

Deepak

unread,
Dec 17, 2009, 8:48:29 AM12/17/09
to
Hi,
I am reading different files and extracting date out of them .
But dates are appearing to be from different timezones ( or from
different countries ) , hence I am receiving
CODE
Exception in thread "main" java.text.ParseException: Unparseable date:
" maandag 19 november 2001 5:48"

while parsing String of date to Date Object .

The code I am using is
CODE
SimpleDateFormat dateFormat = new SimpleDateFormat(" EEEE dd MMMM yyyy
HH:mm");
dateFormat.setTimeZone(TimeZone.getDefault());
date = dateFormat.parse(strDate);


The pattern I am using in the above code is for the date of format
"maandag 19 november 2001 5:48" only , but there are other formats
also .

Please help with the parsing , so that I can save all the dates in
single default timezone .

Thanks in advance.
Deepak

Lew

unread,
Dec 17, 2009, 8:54:18 AM12/17/09
to

Sounds like you need more than one DateFormat created through
<http://java.sun.com/javase/6/docs/api/java/text/DateFormat.html#getDateInstance(int,%20java.util.Locale)>
or other 'Locale'-aware means.

--
Lew

Roedy Green

unread,
Dec 18, 2009, 1:13:11 AM12/18/09
to
On Thu, 17 Dec 2009 05:48:29 -0800 (PST), Deepak
<deepak...@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>
>Please help with the parsing , so that I can save all the dates in
>single default timezone .

see http://mindprod.com/jgloss/calendar.html

After the date is parsed, it is in UTC, not a local timezone. When
you redisplay it, you tweak it with the timezone of the viewer.
--
Roedy Green Canadian Mind Products
http://mindprod.com
The future has already happened, it just isn�t evenly distributed.
~ William Gibson (born: 1948-03-17 age: 61)

0 new messages