This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, java.sql.Date is a thin wrapper of a millisecond value, which enables JDBC to identify it as a SQL date. In the SQL specification there is no time component of a date value, so the hours, minutes, seconds and milliseconds must be zero. All the methods for getting and setting time e.g getHours are deprecated as they serve no purpose. java.util.Date is a class that represents a specific moment in time, with millisecond precision. However it's methods for getting and and setting date and time were not particulary conducive to internationalization and the java.util.Calender class should be used to convert between a date and it's various time fields i.e(YEAR, MONTH e.tc). Also the java.util.DateFormat class should be used to format and parse date strings best regards, Nigel Browne SCJP, SCJD
Joined: Feb 02, 2004
thank you for your response!But I have a new problem. I want a String as such format "2004-02-25 12:05:09". which class and methods can I use? I tried to do this as following: java.util.Date dDate = new java.util.Date(System.currentTimeMillis()); String sDate = dDate.dDate.toLocaleString(); then, I execute my program.... the result: sDate is "2004-02-25 12:05:09" in Windows Environment.(JBuilder9) sDate is "Feb 25, 2004 12:05:09 AM" in Linux Environment. I am very confused about this. What difference can OS make???
and my Linux Environment is as following: [ken@test47 consumer]$ java -version java version "1.3.1_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01) Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode) [ken@test47 consumer]$ uname -a Linux test47 2.4.18-3 #1 Thu Apr 18 07:37:53 EDT 2002 i686 unknown
I have also a question about the Date? I want to find the time between to events so I first use GetDate and then do some processing. Then do another GetDate. How do I find the time between the two events ie How do I subtract time?