Search code examples
androidtimezonemethod-missing

Methods are not available from the class


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?


Solution

  • 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();