Get Time in London

Posted by fahdshariff on Stack Overflow See other posts from Stack Overflow or by fahdshariff
Published on 2010-03-29T18:19:51Z Indexed on 2010/03/29 18:23 UTC
Read the original article Hit count: 426

How can I get the current local wall clock time (in number of millis since 1 Jan 1970) in London? Since my application can run on a server in any location, I think I need to use a TimeZone of "Europe/London". I also need to take Daylight Savings into account i.e. the application should add an hour during the "summer".

I would prefer to use the standard java.util libraries.

Is this correct?

TimeZone tz = TimeZone.getTimeZone("Europe/London") ;
Calendar cal = Calendar.getInstance(tz);
return cal.getTime().getTime() + tz.getDSTSavings();

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about datetime