• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

TimeZones

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

calendar.set(year , month , day , hour , minute , second);
TimeZone timeZone = null;

if ((timezone != null) && (!(timezone.toString().equals(""))))
{
timeZone = TimeZone.getTimeZone(timezone);

if (!timezone.equalsIgnoreCase(timeZone.getID()))
{
String msg = MPWAUtils.getLogMessage(
"error.general.invalid_time");
log.error(msg);
throw new InvalidParameterException(
MPWAConstants.ERRMSG_INVALID_TIME , msg);
}

log.debug("time zone " + timeZone);
calendar.setTimeZone(timeZone);
log.debug("time zone after set in Calendar " + timeZone);
//Generate TimeStamp from Calendar
timeStamp = new Timestamp(calendar.getTime().getTime());




i use above code to check any entered time zone is valid.

i need to check its validity and throw an exception if it is wrong timeZone.

but i dont want the time zone to be converted to default one.

and i need to get all available time zones in the world.

currently TimeZOne.getAvailableZones() will not get all of them\

help me

thanks maoj.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


currently TimeZOne.getAvailableZones() will not get all of them\


Where are you getting your TimeZone object? There is no class in the JDK called TimeZone with a getAvailableZones() method.
 
manoj samarasinghe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is TimeZone.getAvailableIDs() method

i am getting timeZone as Asia/Colombo.
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
currently TimeZOne.getAvailableZones() will not get all of them

What makes you think so?

i am getting timeZone as Asia/Colombo

...and what's wrong with that?
[ February 22, 2005: Message edited by: Dmitry Melnik ]
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic