Results 1 to 3 of 3
  1. #1
    nanaji is offline Member
    Join Date
    May 2008
    Posts
    31
    Rep Power
    0

    Default java new Date() problem

    Hi

    I am not able to get the System date and Time using new Date();

    What might be the problem , can someone give any idea, appreciate.

    Ofcourse, i can set the TimeZone(), it works . I don't want to set anything. I just want to get the System Date. How to get that.

    Thanks
    Nanaji

  2. #2
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    7

    Default

    Hi,
    This gives the correct value...
    Java Code:
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                java.util.Date date = new java.util.Date();
                String datetime = dateFormat.format(date);
                System.out.println("Current Date Time : " + datetime);
    To finish sooner, take your own time....
    Nivedithaaaa

  3. #3
    nanaji is offline Member
    Join Date
    May 2008
    Posts
    31
    Rep Power
    0

    Default

    Hi

    Presnetly i am using the same one. Not working. Actually it suppose to give the SGT time. new Date() is giving GMT time.

Similar Threads

  1. java.util.Date vs java.sql.Date
    By Jack in forum New To Java
    Replies: 5
    Last Post: 10-28-2010, 03:59 PM
  2. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 09:32 PM
  3. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 05:15 PM
  4. problem with date class
    By gabriel in forum New To Java
    Replies: 3
    Last Post: 08-03-2007, 02:28 PM
  5. problem with date field
    By Ed in forum JDBC
    Replies: 2
    Last Post: 06-12-2007, 05:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •