Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TimeZones

 
manoj samarasinghe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
it is TimeZone.getAvailableIDs() method

i am getting timeZone as Asia/Colombo.
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic