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
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Date.html
Date (Java Platform SE 8 )
October 20, 2025 - The arguments are interpreted as a year, month, day of the month, hour of the day, minute within the hour, and second within the minute, exactly as for the Date constructor with six arguments, except that the arguments are interpreted relative to UTC rather than to the local time zone.
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….

🌐
GeeksforGeeks
geeksforgeeks.org › java › date-class-java-examples
Date class in Java (With Examples) - GeeksforGeeks
January 2, 2019 - Date(String s) Note : The last 4 constructors of the Date class are Deprecated. ... // Java program to demonstrate constuctors of Date import java.util.*; public class Main { public static void main(String[] args) { Date d1 = new Date(); ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.util.date.-ctor
Date Constructor (Java.Util) | Microsoft Learn
Portions of this page are modifications ... the Creative Commons 2.5 Attribution License. A constructor used when creating managed representations of JNI objects; called by the runtime....
🌐
CodeGym
codegym.cc › java blog › java classes › java.util.date class
Java.util.Date Class
February 14, 2025 - This java.util.Date constructor creates a date object the equals the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 GMT.
🌐
Tutorialspoint
tutorialspoint.com › java › java_date_time.htm
Java - Date and Time
Java provides the Date class available in java.util package, this class encapsulates the current date and time. The Date class supports two constructors as shown in the following table.
🌐
Java
download.java.net › java › early_access › loom › docs › api › java.sql › java › sql › Date.html
Date (Java SE 25 & JDK 25 [build 1])
Constructor · Description · Date · (int year, int month, int day) Deprecated. instead use the constructor Date(long date) Date · (long date) Constructs a Date object using the given milliseconds time value. All MethodsStatic MethodsInstance MethodsConcrete MethodsDeprecated Methods ·
🌐
Scaler
scaler.com › home › topics › java.util.date class
java. util.Date Class - Scaler Topics
December 13, 2022 - The most common way to declare the java util date class is as follows- We have used the Date() constructor which is the most basic constructor of java. util.Date class.
Find elsewhere
🌐
W3Schools
w3schools.com › java › java_date.asp
Java Date and Time
Enums Enum Constructor Java User Input Java Date · Java Errors Java Debugging Java Exceptions Java Multiple Exceptions Java try-with-resources · Java Files Java Create Files Java Write Files Java Read Files Java Delete Files · Java I/O Streams Java FileInputStream Java FileOutputStream Java BufferedReader Java BufferedWriter ·
🌐
TutorialsPoint
tutorialspoint.com › how-to-create-date-object-in-java
How to create date object in Java?
You can create a Date object using the Date() constructor of java.util.Date constructor as shown in the following example. The object created using this constructor represents the current time.
Top answer
1 of 4
7

Date doesn't have a format. It's just an instant in time, with no associated calendar or time zone. When you need to format a Date, you would often use a DateFormat which is told the calendar system to use, the time zone to convert the instant into a local time etc.

When you print out a Date as you're doing in the second snippet, implicitly via toString(), that will always use the system default time zone, and an unmodifiable format. (It may or may not change with system locale - I'm not sure). Basically that should only be used for debugging. If you want any sort of control over the text, DateFormat is where it's at.

If you want to be able to simply construct date values from year/month/day etc, I'd recommend you look at Joda Time - it's a much saner date/time API than Java's. It makes all kinds of things much cleaner, including the separation of "local time", "local date", "local date and time", "date and time in a particular time zone" etc.

2 of 4
3

You can make a new Date by calling the constructor.

// you specify year1, month1, day1
DateClass d = new DateClass(new Date(year1-1900, month1-1, day1),
    new Date (year2-1900, month2-1, day2);

This is the simplest way, and will certainly work; however, as Carlos Heuberger correctly notes, this is deprecated, meaning that other ways are preferred. You can also make a new Date through DateFormat:

DateFormat df = new SimpleDateFormat("MM-dd-yyyy");
Date d1 = df.parse("12-10-2011"); // for example, today's date
Date d2 = df.parse("01-01-1900"); // use your own dates, of course

To be able to print in mm-dd-yyyy format, implement toString:

public String toString(){
    DateFormat df = new SimpleDateFormat("MM-dd-yyyy");
    return "Date 1: " + df.format(d1) + " Date 2: " + df.format(d2);
}
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › util › Date.html
Date (Java Platform SE 7 )
The arguments are interpreted as a year, month, day of the month, hour of the day, minute within the hour, and second within the minute, exactly as for the Date constructor with six arguments, except that the arguments are interpreted relative to UTC rather than to the local time zone.
🌐
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. A 'Calendar' instance should be used instead.
🌐
Oracle
docs.oracle.com › javame › config › cldc › ref-impl › cldc1.0 › jsr030 › java › util › Date.html
java.util Class Date
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. It allowed the interpretation of dates as year, month, day, hour, minute, and second values. It also allowed the formatting and parsing of date strings.
🌐
JavaMadeSoEasy
javamadesoeasy.com › 2015 › 07 › forming-date-manually-using.html
JavaMadeSoEasy.com (JMSE): Forming date MANUALLY using java.util.Date’s constructor, GregorianCalendar’s constructor and set method in java
Program 1) Forming date manually using following java.util.Date’s constructor > Program 2) Forming date manually using following GregorianCalendar’s constructor > Program 3.1) Forming date manually using following GregorianCalendar’s set method > Program 3.2) Forming date manually using following GregorianCalendar’s set method > Program 1) Forming date manually using following java.util.Date’s constructor > new Date(YEAR - 1900, MONTH, DATE); new Date(YEAR - 1900, MONTH, DATE, HOUR, MINUTE, SECOND); Note: Both constructors are deprecated ·
🌐
TutorialsPoint
tutorialspoint.com › java › util › java_util_date.htm
Java Date Class
package com.tutorialspoint; import java.time.Instant; // Import the Date package import java.util.Date; // Main public class public class DateDemo { public static void main(String[] args) { // create a date of current time Date date = Date.from(Instant.now()); // print the date instance ...
🌐
Coderanch
coderanch.com › t › 623627 › java › constructor-Date-int-int-int
The constructor Date(int, int, int) is deprecated issue (Beginning Java forum at Coderanch)
Beginning Java · Dade Murphy · Ranch Hand · Posts: 30 · posted 11 years ago · Number of slices to send: Optional 'thank-you' note: Send · This practice app I wrote takes a set of dates and checks to see if the date is a palindrome 11022011 it will return Wed Nov 02 00:00:00 CDT 2011. This works great i was able to to get this done. I want to upgrade my code because the of the warning i am getting "The constructor Date(int, int, int) is deprecated issue" I have listed the Main and the PalindromeDate class.
🌐
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
🌐
MIT
web.mit.edu › java_v1.0.2 › www › javadoc › java.util.Date.html
Class java.util.Date
Creates a date from a string according to the syntax accepted by parse().