aspose file tools
The moose likes Beginning Java and the fly likes ClassCastException  - SimpleTimeZone Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "ClassCastException  - SimpleTimeZone " Watch "ClassCastException  - SimpleTimeZone " New topic
Author

ClassCastException - SimpleTimeZone

Himadri Joshi
Greenhorn

Joined: Jul 21, 2006
Posts: 28
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
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
You don't have to get the timeZone of the GregorianCalendar.
Just create your own and pass that to the calendar.

Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12907
    
    3

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: ClassCastException - SimpleTimeZone
 
Similar Threads
abstract method TimeZone.getRawOffset
Getting Default TimeZoneID, rawoffset
calendar.setTime() problem
java.util.Date version conflict
Calendar Conversions