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 5 of 5

Thread: UTC Dates

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default UTC Dates

    Hello.

    I already search by this topic in the forum searh engine , and i have found a lot of issues related with this topic but none of these have clarified me.
    I read that when you create a Date object like this away Date d = new Date(); , that will contain the date in UTC(number of miliseconds since 01/01/1970), but when i simple
    do System.out.println(d) this will print the date in my local machine timezone.
    How can I hava a Date object with the UTC time ?

    Thanks


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    491
    Thanks
    8
    Thanked 47 Times in 45 Posts

  3. #3
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Location
    Wales, Bangor & England, Warwickshire
    Posts
    820
    My Mood
    Cynical
    Thanks
    7
    Thanked 104 Times in 90 Posts

    Default Re: UTC Dates

    Thank you Pedro for searching the forums before asking, we greatly appreciate this.

    You can you d.getTime() to get the number of milliseconds

    I hope that helps.

    Regards,
    Chris
    chris[at]javaprogrammingforums[dot]com

    Prifysgol Bangor University, North Wales

  4. #4
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    491
    Thanks
    8
    Thanked 47 Times in 45 Posts

    Default Re: UTC Dates

    Chris, do you really believe that someone who posted the identical same matter, typos and all, on [at least] three forums did really "search by this topic in the forum searh engine"? Especially seeing as how the question was adequately answered on the other two forums well before you posted your response but the OP didn't deign to inform us of that here.

    Incidentally the forum search on the Sun/Oracle forums has been broken for quite some time and doesn't return meaningful results. Those of us who post there regularly use Google with the site: qualifier to find old posts we remember and would like to link to in a current thread.

    db

  5. #5
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    491
    Thanks
    8
    Thanked 47 Times in 45 Posts

    Default Re: UTC Dates

    Oh, here's one more
    java.net Forums : UTC Dates ...

    db

Similar Threads

  1. [SOLVED] Java program to sort arrays containing dates
    By scottyadam in forum Collections and Generics
    Replies: 1
    Last Post: March 9th, 2009, 06:08 PM

Tags for this Thread