The java.util.Date class isn't actually deprecated, just that constructor, along with a couple other constructors/methods are deprecated. It was deprecated because that sort of usage doesn't work well with internationalization. The Calendar class should be used instead:

Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1988);
cal.set(Calendar.MONTH, Calendar.JANUARY);
cal.set(Calendar.DAY_OF_MONTH, 1);
Date dateRepresentation = cal.getTime();

Take a look at the date Javadoc:

http://download.oracle.com/javase/6/docs/api/java/util/Date.html

Answer from BuffaloBuffalo on Stack Overflow
Top answer
1 of 14
296

The java.util.Date class isn't actually deprecated, just that constructor, along with a couple other constructors/methods are deprecated. It was deprecated because that sort of usage doesn't work well with internationalization. The Calendar class should be used instead:

Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1988);
cal.set(Calendar.MONTH, Calendar.JANUARY);
cal.set(Calendar.DAY_OF_MONTH, 1);
Date dateRepresentation = cal.getTime();

Take a look at the date Javadoc:

http://download.oracle.com/javase/6/docs/api/java/util/Date.html

2 of 14
150

tl;dr

LocalDate.of( 1985 , 1 , 1 )  // Months 1-12 for January-December. 

…or…

LocalDate.of( 1985 , Month.JANUARY , 1 )

Details

The java.util.Date, java.util.Calendar, and java.text.SimpleDateFormat classes were rushed too quickly when Java first launched and evolved. The classes were not well designed or implemented. Improvements were attempted, thus the deprecations you’ve found. Unfortunately the attempts at improvement largely failed. You should avoid these classes altogether. They are supplanted in Java 8 by new classes.

Problems In Your Code

A java.util.Date has both a date and a time portion. You ignored the time portion in your code. So the Date class will take the beginning of the day as defined by your JVM’s default time zone and apply that time to the Date object. So the results of your code will vary depending on which machine it runs or which time zone is set. Probably not what you want.

If you want just the date, without the time portion, such as for a birth date, you may not want to use a Date object. You may want to store just a string of the date, in ISO 8601 format of YYYY-MM-DD. Or use a LocalDate object from Joda-Time (see below).

Joda-Time

First thing to learn in Java: Avoid the notoriously troublesome java.util.Date & java.util.Calendar classes bundled with Java.

As correctly noted in the answer by user3277382, use either Joda-Time or the new java.time.* package in Java 8.

Example Code in Joda-Time 2.3

DateTimeZone timeZoneNorway = DateTimeZone.forID( "Europe/Oslo" );
DateTime birthDateTime_InNorway = new DateTime( 1985, 1, 1, 3, 2, 1, timeZoneNorway );

DateTimeZone timeZoneNewYork = DateTimeZone.forID( "America/New_York" );
DateTime birthDateTime_InNewYork = birthDateTime_InNorway.toDateTime( timeZoneNewYork ); 

DateTime birthDateTime_UtcGmt = birthDateTime_InNorway.toDateTime( DateTimeZone.UTC );

LocalDate birthDate = new LocalDate( 1985, 1, 1 );

Dump to console…

System.out.println( "birthDateTime_InNorway: " + birthDateTime_InNorway );
System.out.println( "birthDateTime_InNewYork: " + birthDateTime_InNewYork );
System.out.println( "birthDateTime_UtcGmt: " + birthDateTime_UtcGmt );
System.out.println( "birthDate: " + birthDate );

When run…

birthDateTime_InNorway: 1985-01-01T03:02:01.000+01:00
birthDateTime_InNewYork: 1984-12-31T21:02:01.000-05:00
birthDateTime_UtcGmt: 1985-01-01T02:02:01.000Z
birthDate: 1985-01-01

java.time

In this case the code for java.time is nearly identical to that of Joda-Time.

We get a time zone (ZoneId), and construct a date-time object assigned to that time zone (ZonedDateTime). Then using the Immutable Objects pattern, we create new date-times based on the old object’s same instant (count of nanoseconds since epoch) but assigned other time zone. Lastly we get a LocalDate which has no time-of-day nor time zone though notice the time zone applies when determining that date (a new day dawns earlier in Oslo than in New York for example).

ZoneId zoneId_Norway = ZoneId.of( "Europe/Oslo" );
ZonedDateTime zdt_Norway = ZonedDateTime.of( 1985 , 1 , 1 , 3 , 2 , 1 , 0 , zoneId_Norway );

ZoneId zoneId_NewYork = ZonedId.of( "America/New_York" );
ZonedDateTime zdt_NewYork = zdt_Norway.withZoneSameInstant( zoneId_NewYork );

ZonedDateTime zdt_Utc = zdt_Norway.withZoneSameInstant( ZoneOffset.UTC );  // Or, next line is similar.
Instant instant = zdt_Norway.toInstant();  // Instant is always in UTC.

LocalDate localDate_Norway = zdt_Norway.toLocalDate();

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.

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

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

You may exchange java.time objects directly with your database. Use a JDBC driver compliant with JDBC 4.2 or later. No need for strings, no need for java.sql.* classes. Hibernate 5 & JPA 2.2 support java.time.

Where to obtain the java.time classes?

  • Java SE 8, Java SE 9, Java SE 10, Java SE 11, and later - Part of the standard Java API with a bundled implementation.
    • Java 9 brought some minor features and fixes.
  • Java SE 6 and Java SE 7
    • Most of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen-Backport.
  • Android
    • Later versions of Android (26+) bundle implementations of the java.time classes.
    • For earlier Android (<26), the latest Android tooling enables a process known as API desugaring to provide a subset of the java.time functionality not originally built into Android.
      • If the desugaring does not offer what you need, the ThreeTenABP project adapts ThreeTen-Backport (mentioned above) to Android. See How to use ThreeTenABP….

🌐
Reddit
reddit.com › r/java › should java.util.date be deprecated?
r/java on Reddit: Should java.util.Date be deprecated?
May 10, 2022 - ... And this is the reason why java.util.Date will likely never be marked as deprecated for removal. Removing that class will probably break binary compatibility with every JDBC driver and application out there.
🌐
Coderanch
coderanch.com › t › 688059 › java › Java-Date-deprecated
Why Java Date is deprecated? (Java in General forum at Coderanch)
That should be java.util.Date, not java.lang.Date. It's not important enough to be in java.lang · SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6 How To Ask Questions How To Answer Questions ... If you ever use the newer date and time API, you will find it so much better than Date/Calendar that you will never want to use Date again. Oracle have recently been going through the public API and deprecating lots of classes and methods.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Date.html
Date (Java Platform SE 8 )
October 20, 2025 - Deprecated. As of JDK version 1.1, replaced by DateFormat.format(Date date). Creates a string representation of this Date object in an implementation-dependent form. The intent is that the form should be familiar to the user of the Java application, wherever it may happen to be running.
🌐
Jsparrow
jsparrow.github.io › rules › date-deprecated.html
Remove Deprecated Date Constructs | jSparrow Documentation
Some java.util.Date constructors like new Date(int year, int month, int day), new Date(int year, int month, int date, int hrs, int min) and new Date(int year, int month, int date, int hrs, int min, int sec) are deprecated and the Calendar should be used instead.
🌐
OpenJDK
mail.openjdk.org › pipermail › discuss › 2022-May › 006077.html
Deprecating java.util.Date, java.util.Calendar and java.text.DateFormat and their subclasses
On the positive impact side, more than just discouraging the usage of the ugly and annoying API of Date, Calendar and DateFormat for people who should know better, those classes are a frequent source of bugs that are hard do track and to debug due to their mutability and thread unsafety. Thus, we are already way past the time to make the compiler give a warning to anyone still using them. What do you think? Next message (by thread): Deprecating java.util.Date, java.util.Calendar and java.text.DateFormat and their subclasses
🌐
Medium
medium.com › @haiou-a › java-why-is-the-date-class-now-discouraged-e31d9f9014a1
JAVA: Why Is the Date Class Now Discouraged? | by Oliver Foster | Medium
February 4, 2025 - java.util.Date (hereafter referred to as Date) is a terrible type, which explains why most of its functionality was deprecated in Java 1.1 (but, unfortunately, it’s still in use).
🌐
Utah Amateur Radio Club
user.xmission.com › ~goodhill › dates › datedeprecation.htm
java.util.Date Deprecated?
java.util.Dates we see that of its 6 constructors, only two are not deprecated.
🌐
In Relation To
in.relation.to › 2024 › 04 › 22 › stop-using-date
It's long past time to stop using Date - In Relation To
These are the types you should use to represent dates, times, and datetimes in your entity classes. Therefore, JPA 3.2 deprecates: the @Temporal and @MapKeyTemporal annotations, the TemporalType enumeration, and ·
Find elsewhere
🌐
Programming Hints
programminghints.com › home › still using java.util.date? don’t!
Still using java.util.Date? Don't! - Programming Hints
June 23, 2017 - New Date and Time API is available since Java 8. It is simpler, flexible, immutable... Yet, I still see developers using old java.util.Date. Don't!
🌐
Coderanch
coderanch.com › t › 662864 › java › java-util-Date-setYear-deprecated
java.util.Date.setYear() deprecated (Beginning Java forum at Coderanch)
When something is deprecated in the API there's usually an accompanying note in the JavaDocs about what to use instead. I'd bet there's one that can help you in this case. ... Use class java.util.Calendar instead, or better, if you are using Java 8, use the classes from the java.time package ...
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)

🌐
Quora
quora.com › Why-is-Date-int-year-int-month-int-date-deprecated-in-Java-and-what-replaced-it
Why is Date(int year, int month, int date) deprecated in Java and what replaced it? - Quora
Answer (1 of 2): Date as a whole is not deprecated, just most of the included methods that talk of days months hours etc. including the constructor you mention. Date is internally just a number (the number of seconds since the Unix epoch 1st ...
🌐
OpenJDK
cr.openjdk.org › ~sherman › threeten › old › deprecated-list.html
Deprecated List (ThreeTen date and time API)
JavaScript is disabled on your browser · Overview · Package · Class · Deprecated · Index · Frames · No Frames · All Classes · Deprecated API
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › util › Date.html
Date (Java Platform SE 7 )
Deprecated. As of JDK version 1.1, replaced by DateFormat.format(Date date). Creates a string representation of this Date object in an implementation-dependent form. The intent is that the form should be familiar to the user of the Java application, wherever it may happen to be running.
🌐
Oracle
docs.oracle.com › en › java › javase › 12 › docs › api › java.base › java › util › Date.html
Date (Java SE 12 & JDK 12 )
Deprecated. As of JDK version 1.1, replaced by DateFormat.format(Date date). Creates a string representation of this Date object in an implementation-dependent form. The intent is that the form should be familiar to the user of the Java application, wherever it may happen to be running.
🌐
Code2care
code2care.org › home page › java › why avoid java util date calendar classes
Deep Dive: Why avoid java.util.Date and Calendar Classes | Code2care
If you have spend a good amount of time programming in Java (old enough that you have worked with Java 7 or below), you must have realized how inefficient and poorly designed the java.util.Date and java.util.Calander classes are. Just try to look for any questions related to java.util.Date class on Stackoverflow almost all the answers say "Avoid using the Date class".
🌐
UNICAMP
dca.fee.unicamp.br › projects › sapiens › calm › References › Java › tutorial › post1.0 › converting › deprecated.html
Alternatives to Deprecated Methods in java.lang, java.net, and java.util
Now programmers should explicitly ... Datagrams, respectively. Many of the methods in java.util.Date have been deprecated in favor of other APIs that better support internationalization....