"converting the “america/los angeles” time zone to “pst” or “pdt” in java me" Code Answer

2

may be this is what you are wanting. this works on my machine using standard java.

        calendar calendar = calendar.getinstance();       
        timezone tz = timezone.gettimezone("america/los_angeles");
        calendar.settimezone(tz);
         system.out.println("offset from utc="+tz.getoffset(calendar.gettimeinmillis())/(60*60*1000)); //prints -8
        system.out.println(tz.getdisplayname(boolean.true, 0)); //prints pdt
        system.out.println(tz.getdisplayname(boolean.true, 1)); //prints pacific daylight time
        system.out.println(tz.getdisplayname(boolean.false, 0));//prints pst
        system.out.println(tz.getdisplayname(boolean.false, 1));//prints pacific standard time  

update: op said the above does not work for j2me. after googling i found here that getoffset() is actually getrawoffset() in j2me. however, it does not look like it supposrts displayname. your only option i think is to go through the ids using getavailableids().

By Dan Healy on August 7 2022

Answers related to “converting the “america/los angeles” time zone to “pst” or “pdt” in java me”

Only authorized users can answer the Search term. Please sign in first, or register a free account.