I have doubt regarding the Date object creation by using Date() method. While creating Date() object, will it takes local time from system for this?
-
http://docs.oracle.com/javase/7/docs/api/java/util/Date.html – Paul Samsotha Dec 04 '13 at 16:39
2 Answers
Yes.
From the Javadoc:
Date()
Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
But, java.util.Date is notoriously poorly regarded. Most would recommend that you use Joda-Time's LocalDate instead.

- 1
- 1

- 417
- 4
- 14
-
and what is so poor about java.util.Date, if you ignore the deprecated stuff? Works just fine for me. – Gimby Dec 04 '13 at 17:00
-
1See [this thread](http://stackoverflow.com/questions/12032051/differences-between-java-util-date-and-joda-time-apis) or have a google. Several prominent Java designers/bloggers discuss the topic at length. Alternatively, read the Joda brief [here](http://joda-time.sourceforge.net/old-index.html) – alexvinall Dec 04 '13 at 17:25
My answer to the question about local time or not, is NO.
We have to differentiate: Date() no-arg-constructor is based on System.currentTimeMillis() which is a globally equal representation of milliseconds since UNIX epoch (not counting leap seconds). This count is everywhere on this globe the same, correct os clock setting provided. => hence no local time
But be aware of the fact that the representation of java.util.Date via toString() IS LOCAL, meaning dependent on default time zone setting of jvm. This is one of many prominent examples of confusion which are caused by java.util.Date.

- 42,708
- 7
- 104
- 126
-
The correct answer makes a very important point: what is stored internally and what is rendered for display to the user are two different things. That is why for rendering we apply a time zone and locale in both worlds of j.u.Date/Calendar and [Joda-Time](http://www.joda.org/joda-time/) – Basil Bourque Dec 04 '13 at 17:40