• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic