• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SimpleDateFormat parse() gives incorrect result

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dfault TimeZone GMT-3.00.
I am parsing new Date("1900/01/01").toString using the parse method of SimpleDateFormat.

The Result i get is
Sun Dec 31 23:15:16 UYT 1899
instead of
Mon Jan 01 00:00:00 UYT 1900

I can't understand why is the result different.

PS: If i change the TimeZone to GMT +5.30 the result is as expected.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try with SimpleDateFormate and Local ,

SimpleDateFormat df=new SimpleDateFormat("yyyy/MM/dd",Locale.US);
Date date= df.parse("1900/01/01");
System.out.println("date:"+date);

Regards,
Ravi
reply
    Bookmark Topic Watch Topic
  • New Topic