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

  • Follow


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
0
Reply deepak.kadu80 (1) 12/17/2009 1:48:29 PM

Deepak wrote:
>      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 .

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
0
Reply Lew 12/17/2009 1:54:18 PM


On Thu, 17 Dec 2009 05:48:29 -0800 (PST), Deepak
<deepak.kadu80@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
Reply Roedy 12/18/2009 6:13:11 AM

2 Replies
756 Views

(page loaded in 0.079 seconds)

Similiar Articles:




7/20/2012 10:40:37 PM


Reply: