I am trying to get “TimeZoneOffset” in java and with reference to this, I implemented this:
long unix_time_at_midnight;
DateFormat dateFormat= new SimpleDateFormat("MM/dd/yyyy");
Date d = new Date((unix_time*1000)/1000);
String d1 = dateFormat.format(d);
unix_time_at_midnight = Long.parseLong(d1);
int m=TimeZone.getOffset(unix_time_at_midnight) ;
I get “The method getOffset(int, int, int, int, int, int) in the type TimeZone is not applicable for the arguments (long)”. Can anyone guide?
The method
Timezone.getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds);is an abstract class and one has to reference it from a implementedTimezonesubclass.You’re trying to access a non-static method statically, and the compiler is matching it to the abstract method.
The solution you’re seeking of is:
EDIT: Looking on
TimeZoneon BlackBerry API, I see there is nogetOffset(long date)method, butgetOffset(int era, int year, int month, int day, int dayOfWeek, int millis).A possible solution might be: