eclipse - Not getting the correct timezone in java -


the code using current timezone in java side follows:

calendar calendar = calendar.getinstance(timezone.gettimezone("america/los_angeles"));  system.out.println("the timezone is--->"+(timezone.gettimezone("america/los_angeles")).getdisplayname()); 

it displaying pacific standard time current time zone in america/los angeles pacific daylight time

can me this?

you're calling parameterless getdisplayname() method documentation includes:

this method equivalent to:

 getdisplayname(false, long, locale.getdefault(locale.category.display)) 

the false here argument specifies "don't use daylight saving time". parameterless method never display dst variation.

it's not clear should display name based on current standard/daylight part - if want to, can use:

string name = zone.getdisplayname(zone.indaylighttime(new date()), timezone.long,                                   locale.getdefault(locale.category.display)); 

obviously should customize second , third parameters according requirements.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -