Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Problem in getting time of different time zone

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Location
    noida
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem in getting time of different time zone

    TimeZone timeZone1 = TimeZone.getTimeZone("America/Los_Angeles");
    TimeZone timeZone2 = TimeZone.getTimeZone("Europe/Copenhagen");
    Calendar calendar = new GregorianCalendar(timeZone1);
    System.out.println("Time in LA: "+calendar.getTime());

    I run this code but it is not working and giving me the current time in current time zone.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,364
    My Mood
    Mellow
    Thanks
    143
    Thanked 598 Times in 585 Posts

    Default Re: Problem in getting time of different time zone

    You might find a solution by studying the Calendar API. I'm not sure what you mean by "the current time in the current time zone," but you might try getting a Calendar instance specifying the time zone, locale, or both.

Similar Threads

  1. Java Calendar printing wrong Time Zone?
    By jean28 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 2nd, 2013, 04:59 AM
  2. Using Date() to get Start Time and Finish Time of a copyFiles method
    By dalythe in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: June 17th, 2013, 09:50 PM
  3. Hello, first time caller long time programmer....
    By P2C2N in forum Member Introductions
    Replies: 3
    Last Post: December 10th, 2012, 10:53 AM
  4. Replies: 2
    Last Post: October 19th, 2012, 03:32 AM
  5. [SOLVED] problem with time manipulation!
    By arvindbis in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 30th, 2011, 02:47 PM