In addition to all the comments, I thought I might add some code on how to use java.util.Date, java.util.Calendar and java.util.GregorianCalendar according to the javadoc.

//Initialize your Date however you like it.
Date date = new Date();
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
int year = calendar.get(Calendar.YEAR);
//Add one to month {0 - 11}
int month = calendar.get(Calendar.MONTH) + 1;
int day = calendar.get(Calendar.DAY_OF_MONTH);
Answer from fasholaide on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › › › › java › util › Date.html
Date (Java Platform SE 8 )
October 20, 2025 - java.util.Date · All Implemented ... class Date extends Object implements Serializable, Cloneable, Comparable<Date> The class Date represents a specific instant in time, with millisecond precision....
🌐
Jon Skeet's Coding Blog
codeblog.jonskeet.uk › 2017 › 04 › 23 › all-about-java-util-date
All about java.util.Date | Jon Skeet's coding blog
May 23, 2017 - A Date instance represents an instant in time, not a date. Importantly, that means: It doesn’t have a time zone. It doesn’t have a format. It doesn’t have a calendar system. ... java.util.Date (just Date from now on) is a terrible type, which explains why so much of it was deprecated in Java 1.1 (but is still being used, unfortunately).
Discussions

Understanding Java util Date - Stack Overflow
Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal. ... Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives ... Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Why does java.util... More on stackoverflow.com
🌐 stackoverflow.com
Converting a string into a java.util.Date
I have a string i created with python to input to a Popup Calender. When I try to link it to the date, I get the Error: can't convert 'Thu Aug 21 16:56:40 EDT 2014' to java.util.Date How do i convert a string into… More on forum.inductiveautomation.com
🌐 forum.inductiveautomation.com
0
June 19, 2014
Why is the Java date API (java.util.Date, .Calendar) such a mess? - Stack Overflow
I think it's mess, because everything that changes leaves a mess if you evolve from one level of understanding (XMLGregorianCaldender vs. Date) and requirements (Nanoseconds, past 2030) to higher level, but keeping the old untouched. And java.util.Date is not a Exception. More on stackoverflow.com
🌐 stackoverflow.com
datetime - Why were most java.util.Date methods deprecated? - Stack Overflow
When you look at the javadoc of the java.util.Date class, most of the methods are deprecated. Why was this done? More on stackoverflow.com
🌐 stackoverflow.com
🌐
CodeGym
codegym.cc › java blog › java classes › java.util.date class
Java.util.Date Class
February 14, 2025 - What is java.util.Date Class? The java.util.Date class provides the date and time in java. This class provides constructors and methods to use the current date and time. To use this class in your code you...
🌐
GeeksforGeeks
geeksforgeeks.org › java › util-date-class-methods-java-examples
util.date class methods in Java with Examples - GeeksforGeeks
September 8, 2021 - Syntax: public String toString() Return: a string representation of the given date. .setTime() : java.util.Date.setTime() method is a java.util.Date class method.
Top answer
1 of 3
4

Just follow the javadoc, as it says:

public String toString()

Converts this Date object to a String of the form:

dow mon dd hh:mm:ss zzz yyyy

zzz is the time zone (and may reflect daylight saving time).

And when you dive into the source code, that this toString() implementation will at some point use TimeZone.getDefault() ( or to be precise: getDefaultRef()). In other words: the default implementation pulls in the "default" timezone of your JVM.

2 of 3
3

tl;dr

Current moment in UTC.

Instant.now()    // Capture current moment in UTC.
    .toString()  // Generate String in standard ISO 8601 format.

2018-01-23T01:23:45.677340Z

Current moment in India time zone.

ZonedDateTime.now( 
    ZoneId.of( "Asia/Kolkata" ) 
).toString()    // Generate string in format wisely extended from ISO 8601 standard, adding the time zone name in square brackets.

2018-01-23T06:53:45.677340+05:30[Asia/Kolkata]

Avoid legacy date-time classes

Why does java.util.Date object show date & time with respect to a timezone when in actuality, java.util.Date represents an instant on the time-line, not a "date"?

Because the java.util.Date and related classes (Calendar, SimpleDateFormat, and such) are poorly-designed. While a valiant effort at tackling the tricky subject of date-time handling, they fall short of the goal. They are riddled with poor design choices. You should avoid them, as they are now supplanted by the java.time classes, an enormous improvement.

Specifically to answer your question: The toString method of Date dynamically applies the JVM’s current default time zone while generating a String. So while the Date object itself represents a moment in UTC, the toString creates the false impression that it carries the displayed time zone.

Even worse, there is a time zone buried inside the Date object. That zone is used internally, yet is irrelevant to our discussion here. Confusing? Yes, yet another reason to avoid this class.

A java.util.Date instance has no concept of time-zone.

Not true. A Date represents a specific moment, a point on the timeline, with a resolution of milliseconds, in UTC. As you mention, it is defined as a count of milliseconds since the first moment of 1970 in UTC.

java.time

The java.time classes separate clearly the concepts of UTC, zoned, and unzoned values.

The java.time.Instant class represents a moment on the timeline in UTC with a resolution of nanoseconds (up to nine (9) digits of a decimal fraction). This class replaces java.util.Date.

Instant instant = Instant.now() ;  // Capture current moment in UTC.

Apply a time zone (ZoneId object) to an Instant and you get a ZonedDateTime object. That class replaces the java.util.Calendar class.

ZoneId z = ZoneId.of( "Asia/Kolkata" ) ;
ZonedDateTime zdt = instant.atZone( z ) ;  // Same simultaneous moment as `instant`, but different wall-clock time.

If a value has only an offset-from-UTC but not a full time zone, use the OffsetDateTime class.

For a date only, without time-of-day and without time zone, use the LocalDate class. This class replaces the java.sql.Date class. Ditto for LocalTime replacing java.sql.Time.

LocalDate xmasDate2018 = LocalDate.of( 2018 , Month.DECEMBER , 25 ) ;

If the zone or offset are unknown or indeterminate, such as "Christmas starts at stroke of midnight on December 25, 2018", use the LocalDateTime class. This class does not represent an actual moment, a specific point on the timeline. This class lacks any concept of time zone or offset. So it can only represent potential moments along a range of about 26-27 hours.

LocalDateTime xmasEverywhere2018 = LocalDateTime.of( xmasDate2018 , LocalTime.MIN ) ;

Or…

LocalDateTime xmasEverywhere2018 = LocalDateTime.of( 2018 , Month.DECEMBER , 25 , 0 , 0 , 0 , 0 ) ;

About java.time

The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date, Calendar, & SimpleDateFormat.

The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.

To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.

With a JDBC driver complying with JDBC 4.2 or later, you may exchange java.time objects directly with your database. No need for strings or java.sql.* classes.

Where to obtain the java.time classes?

  • Java SE 8, Java SE 9, and later
    • Built-in.
    • Part of the standard Java API with a bundled implementation.
    • Java 9 adds some minor features and fixes.
  • Java SE 6 and Java SE 7
    • Much of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen-Backport.
  • Android
    • Later versions of Android bundle implementations of the java.time classes.
    • For earlier Android, the ThreeTenABP project adapts ThreeTen-Backport (mentioned above). See How to use ThreeTenABP….

The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval, YearWeek, YearQuarter, and more.

Find elsewhere
🌐
W3Schools
w3schools.com › java › java_date.asp
Java Date and Time
If you don't know what a package is, read our Java Packages Tutorial. To display the current date, import the java.time.LocalDate class, and use its now() method:
🌐
Duke
www2.cs.duke.edu › csed › java › jdk1.4.2 › docs › api › java › util › Date.html
Date (Java 2 Platform SE v1.4.2)
Allocates a Date object and initializes it so that it represents the date and time indicated by the string s, which is interpreted as if by the parse(java.lang.String) method.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.util.date.-ctor
Date Constructor (Java.Util) | Microsoft Learn
Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT. Java documentation for java.util.Date.Date(long).
🌐
Inductive Automation
forum.inductiveautomation.com › ignition
Converting a string into a java.util.Date - Ignition - Inductive Automation Forum
June 19, 2014 - I have a string i created with python to input to a Popup Calender. When I try to link it to the date, I get the Error: can't convert 'Thu Aug 21 16:56:40 EDT 2014' to java.util.Date How do i convert a string into…
🌐
MIT
web.mit.edu › java_v1.0.2 › www › javadoc › java.util.Date.html
Class java.util.Date
java.lang.Object | +----java.util.Date · public class Date · extends Object A wrapper for a date. This class lets you manipulate dates in a system independent way.
🌐
Apache Commons
commons.apache.org › proper › commons-lang › apidocs › org › apache › commons › lang3 › time › DateUtils.html
DateUtils (Apache Commons Lang 3.20.0 API)
java.lang.Object · org.apache.commons.lang3.time.DateUtils · public class DateUtils extends Object · A suite of utilities surrounding the use of the Calendar and Date object. DateUtils contains a lot of common methods considering manipulations of Dates or Calendars.
🌐
Oracle
docs.oracle.com › javame › config › cldc › ref-impl › cldc1.0 › jsr030 › java › util › Date.html
java.util Class Date
java.lang.Object | +--java.util.Date · public class Date · extends Object · The class Date represents a specific instant in time, with millisecond precision. This Class has been subset for the MID Profile based on JDK 1.3. In the full API, the class Date had two additional functions.
🌐
Android Developers
developer.android.com › api reference › date
Date | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.util.date
Date Class (Java.Util) | Microsoft Learn
The class Date represents a specific instant in time, with millisecond precision. [Android.Runtime.Register("java/util/Date", DoNotGenerateAcw=true)] public class Date : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable, Java.Lang.ICloneable, Java.Lang.IComparable
Top answer
1 of 3
44

Someone put it better than I could ever say it:

  • Class Date represents a specific instant in time, with millisecond precision. The design of this class is a very bad joke - a sobering example of how even good programmers screw up. Most of the methods in Date are now deprecated, replaced by methods in the classes below.
  • Class Calendar is an abstract class for converting between a Date object and a set of integer fields such as year, month, day, and hour.

  • Class GregorianCalendar is the only subclass of Calendar in the JDK. It does the Date-to-fields conversions for the calendar system in common use. Sun licensed this overengineered junk from Taligent - a sobering example of how average programmers screw up.

from Java Programmers FAQ, version from 07.X.1998, by Peter van der Linden - this part was removed from later versions though.

As for mutability, a lot of the early JDK classes suffer from it (Point, Rectangle, Dimension, ...). Misdirected optimizations, I've heard some say.

The idea is that you want to be able to reuse objects (o.getPosition().x += 5) rather than creating copies (o.setPosition(o.getPosition().add(5, 0))) as you have to do with immutables. This may even have been a good idea with the early VMs, while it's most likely isn't with modern VMs.

2 of 3
21

Java's early APIs are nothing more than a product of their time. Immutability only became a popular concept years after that. You say that immutability is "obvious". That might be true now but it wasn't then. Just like dependency injection is now "obvious" but it wasn't 10 years ago.

It was also at one time expensive to create Calendar objects.

They remain that way for backwards compatibility reasons. What is perhaps more unfortunate was that once the mistake was realized the old class wasn't deprecated and new date/time classes were created for all APIs going forward. This has to some degree occurred with the JDK 8 adoption of a JodaTime like API (java.time, JSR 310) but really it's too little too late.

🌐
PTC Community
community.ptc.com › t5 › Windchill › Adding-Years-to-a-Java-util-date › td-p › 110809
Adding Years to a Java.util.date - PTC Community
May 2, 2018 - I have a simple task that I am struggling with. We could work around it, but I'd like to automate as much as possible for my users in an effort to make it easier for them. I have a workflow that has a variable for them to enter a date. I want to be able to add 4 years to that date by using ...
Top answer
1 of 5
44

Well, for two related reasons. It was a very poor implementation of the concept of Dates and Times and it was replaced by the Calendar class.

The Calendar class, although an improvement, leaves a lot to be desired as well, so for serious Date/Time work, everyone recommends Joda-Time. Java 8 brings the new java.time.* package, inspired by Joda-Time, defined by JSR-310, and intended to supplant the old Date/Calendar classes.

Edit: In response to the specific question of why the implementation is poor, there are many reasons. The JavaDoc sums it up as follows:

Unfortunately, the API for these functions was not amenable to internationalization.

In addition to this general deficiency (which covers issues like the lack of a Time Zone component as well as the date formatting which is better handled in DateFormat and the inability to have a non-Gregorian calendar representation), there are specific issues which really hurt the Date class, including the fact that year is presented in an offset of 1900 from Common Era year.

Calendar has its own problems, but even as early as JDK 1.1 it was obvious that java.util.Date was not going to cut it. Even though Calendar is arguable the worst JDK API, it has taken until version 7 to attempt to address it.

2 of 5
17
  • Date is mutable
  • Date doesn't have support for time zones

The latter led to it being replaced by Calendar. And the former, combined with the ease-of-use, lead to both being replaced by Joda-Time / JSR-310 (java.time.* package)

🌐
The Coding Forums
thecodingforums.com › archive › archive › java
new java.util.Date(0) | Java | Coding Forums
April 16, 2004 - The Date(long) constructor interprets its argument as seconds since 1970-01-01 00:00:00 UTC, but the toString() method produces a representation in the local time zone. (The accuracy of the representation depends on the host system's ability ...