• 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

ClassCastException - SimpleTimeZone

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am upgrading the JRE version from 1.3 to 1.5 and in the process of that I witness ClassCastException being thrwon by the following statement(statement 3)


I am trying to assign the proper gmtoffset based on the current local timezone.
Some research on our end suggests that such casting is not supported in higher version of jre.

Could any one please suggest a workaround for this?

Thanks,
Himadri
 
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have to get the timeZone of the GregorianCalendar.
Just create your own and pass that to the calendar.

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Himadri Joshi:
Some research on our end suggests that such casting is not supported in higher version of jre.


That's because in Java 5, Calendar.getTimeZone() does not return a SimpleTimeZone object. Note that the API documentation just says that it returns a TimeZone. Which subclass of class TimeZone it actually returns is not specified, so you should not rely on it being a SimpleTimeZone.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic