0

I have a project that I need to determine the Time Zone for. The TimeZone class seems perfect for the task:

import java.util.TimeZone;

long tzo = TimeZone.getRawOffset();

However, The getRawOffset method is not available. What am I not understanding?

Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120

1 Answers1

0

getRawOffset() isn't static, so you can't call it on TimeZone. Instead you need an actual TimeZone object.

Probably something like:

int tzo = TimeZone.getDefault().getRawOffset();
patheticpat
  • 861
  • 6
  • 11
  • That's what I needed. One question, based on the documentation, how would I know to access the method this way without trying a bunch of coding first? Just want to be able to help myself better in the future. – Roy Hinkley Dec 22 '12 at 17:39
  • 1
    @AndroidAddict if the method is `static` (like `getDefault()`), you can accesss the method via `ClassName.staticMethod();` Otherwise you have to first make your object (`ClassName c = new ClassName()`) then access the methods (using `c.methodName()`) – A--C Dec 22 '12 at 17:41