Results 1 to 4 of 4
  1. #1
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default problem with date class

    Java Code:
    Date dday1=new Date(2007,6,31);
    Date dday2=new Date(2005,1,1);
    long sDay1=dday1.getTime();
    long sDay2=dday2.getTime();
    System.out.println(""+sDay1+"---"+sDay2);
    it returns to me :1120147200000---1120147200000
    why?

  2. #2
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    You should use the java.text.DateFormat object to print out your Date objects in a more readable format.

  3. #3
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    As for why here is the description of java.util.Date.getTime from the java docs
    "Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object."

  4. #4
    gabriel is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

Similar Threads

  1. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 04:15 PM
  2. problem in wrapper class
    By binoympappachen in forum New To Java
    Replies: 4
    Last Post: 12-13-2007, 12:31 PM
  3. Class problem
    By Deagel in forum New To Java
    Replies: 1
    Last Post: 10-31-2007, 07:33 PM
  4. Problem calling another class
    By adlb1300 in forum New To Java
    Replies: 3
    Last Post: 10-25-2007, 02:05 PM
  5. problem with date field
    By Ed in forum JDBC
    Replies: 2
    Last Post: 06-12-2007, 04: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
  •