I recently had to tell a co-worker not to use SimpleDateFormat in completely new code. If it was marked deprecated I guess this would not have been needed. Answer from frzme on reddit.com
🌐
Reddit
reddit.com › r/java › should java.util.date be deprecated?
r/java on Reddit: Should java.util.Date be deprecated?
May 10, 2022 - To some Java developers, deprecated means "strongly unrecommended; do not use in new code." To JDK developers it means something that: whose use is so egregious that it can reasonably be treated as an error (many people treat compiler warnings as errors), and/or · could reasonably be removed at some point in the future. Put another way, deprecated means "dangerous to leave in; remove even from old code". Date does not satisfy either one of these — while "bad" it can be used correctly and has been (unlike, say, Thread.stop), and it cannot be removed for the reasons Brian listed.
🌐
Medium
medium.com › @techclaw › getting-date-from-calendar-in-java-f437d1147ac8
Getting Date from Calendar in Java | by TechClaw | Medium
August 8, 2023 - Learn how to get the date from the calendar in Java with this comprehensive guide. Find step-by-step instructions, code examples, and…
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Date.html
Date (Java Platform SE 8 )
October 20, 2025 - Java™ Platform Standard Ed. 8 ... The class Date represents a specific instant in time, with millisecond precision.
🌐
CodeGym
codegym.cc › java blog › java classes › java.util.date class
Java.util.Date Class
February 14, 2025 - Introduced in Java 8, it offers classes like LocalDate, LocalTime, LocalDateTime, and ZonedDateTime. These classes tackle all the headaches of the old APIs—time zone issues, thread safety, and more—while providing a clear, modern design. For example, a LocalDate represents just a date without time or time zone information.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › guides › datetime › index.html
Java Date Time APIs
October 20, 2025 - java.time.zone - Classes that support time zones, offsets from time zones, and time zone rules. ... The Date-Time API trail in The Java Tutorial shows how to write code that manipulates date and time values.
🌐
InfluxData
influxdata.com › home › java date format: a detailed guide
Java Date Format: A Detailed Guide | InfluxData
July 12, 2024 - Java provides a rich set of classes and methods for handling this, allowing developers to create applications that are not only accurate but also user-friendly. In this extensive guide, we’ll explore various aspects of date formatting in Java, including classes like LocalDate,LocalTime, LocalDateTime, Timestamp, and Timezone.
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:
Top answer
1 of 9
168

Gotcha: passing 2 as month may give you unexpected result: in Calendar API, month is zero-based. 2 actually means March.

I don't know what is an "easy" way that you are looking for as I feel that using Calendar is already easy enough.

Remember to use correct constants for month:

 Date date = new GregorianCalendar(2014, Calendar.FEBRUARY, 11).getTime();

Another way is to make use of DateFormat, which I usually have a util like this:

 public static Date parseDate(String date) {
     try {
         return new SimpleDateFormat("yyyy-MM-dd").parse(date);
     } catch (ParseException e) {
         return null;
     }
  }

so that I can simply write

Date myDate = parseDate("2014-02-14");

Yet another alternative I prefer: Don't use Java Date/Calendar anymore. Switch to JODA Time or Java Time (aka JSR310, available in JDK 8+). You can use LocalDate to represent a date, which can be easily created by

LocalDate myDate =LocalDate.parse("2014-02-14");
// or
LocalDate myDate2 = new LocalDate(2014, 2, 14);
// or, in JDK 8+ Time
LocalDate myDate3 = LocalDate.of(2014, 2, 14);
2 of 9
80

tl;dr

LocalDate.of( 2014 , 2 , 11 )

If you insist on using the terrible old java.util.Date class, convert from the modern java.time classes.

java.util.Date                        // Terrible old legacy class, avoid using. Represents a moment in UTC. 
.from(                                // New conversion method added to old classes for converting between legacy classes and modern classes.
    LocalDate                         // Represents a date-only value, without time-of-day and without time zone.
    .of( 2014 , 2 , 11 )              // Specify year-month-day. Notice sane counting, unlike legacy classes: 2014 means year 2014, 1-12 for Jan-Dec.
    .atStartOfDay(                    // Let java.time determine first moment of the day. May *not* start at 00:00:00 because of anomalies such as Daylight Saving Time (DST).
        ZoneId.of( "Africa/Tunis" )   // Specify time zone as `Continent/Region`, never the 3-4 letter pseudo-zones like `PST`, `EST`, or `IST`. 
    )                                 // Returns a `ZonedDateTime`.
    .toInstant()                      // Adjust from zone to UTC. Returns a `Instant` object, always in UTC by definition.
)                                     // Returns a legacy `java.util.Date` object. Beware of possible data-loss as any microseconds or nanoseconds in the `Instant` are truncated to milliseconds in this `Date` object.   

Details

If you want "easy", you should be using the new java.time package in Java 8 rather than the notoriously troublesome java.util.Date & .Calendar classes bundled with Java.

java.time

The java.time framework built into Java 8 and later supplants the troublesome old java.util.Date/.Calendar classes.

Date-only

A LocalDate class is offered by java.time to represent a date-only value without any time-of-day or time zone. You do need a time zone to determine a date, as a new day dawns earlier in Paris than in Montréal for example. The ZoneId class is for time zones.

ZoneId zoneId = ZoneId.of( "Asia/Singapore" );
LocalDate today = LocalDate.now( zoneId );

Dump to console:

System.out.println ( "today: " + today + " in zone: " + zoneId );

today: 2015-11-26 in zone: Asia/Singapore

Or use a factory method to specify the year, month, day.

LocalDate localDate = LocalDate.of( 2014 , Month.FEBRUARY , 11 );

localDate: 2014-02-11

Or pass a month number 1-12 rather than a DayOfWeek enum object.

LocalDate localDate = LocalDate.of( 2014 , 2 , 11 );

Time zone

A LocalDate has no real meaning until you adjust it into a time zone. In java.time, we apply a time zone to generate a ZonedDateTime object. That also means a time-of-day, but what time? Usually makes sense to go with first moment of the day. You might think that means the time 00:00:00.000, but not always true because of Daylight Saving Time (DST) and perhaps other anomalies. Instead of assuming that time, we ask java.time to determine the first moment of the day by calling atStartOfDay.

Specify a proper time zone name in the format of continent/region, such as America/Montreal, Africa/Casablanca, or Pacific/Auckland. Never use the 3-4 letter abbreviation such as EST or IST as they are not true time zones, not standardized, and not even unique(!).

ZoneId zoneId = ZoneId.of( "Asia/Singapore" );
ZonedDateTime zdt = localDate.atStartOfDay( zoneId );

zdt: 2014-02-11T00:00+08:00[Asia/Singapore]

UTC

For back-end work (business logic, database, data storage & exchange) we usually use UTC time zone. In java.time, the Instant class represents a moment on the timeline in UTC. An Instant object can be extracted from a ZonedDateTime by calling toInstant.

Instant instant = zdt.toInstant();

instant: 2014-02-10T16:00:00Z

Convert

You should avoid using java.util.Date class entirely. But if you must interoperate with old code not yet updated for java.time, you can convert back-and-forth. Look to new conversion methods added to the old classes.

java.util.Date d = java.util.from( instant ) ;

…and…

Instant instant = d.toInstant() ;


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), a process known as API desugaring brings 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….

UPDATE: The Joda-Time library is now in maintenance mode, and advises migration to the java.time classes. I am leaving this section in place for history.

Joda-Time

For one thing, Joda-Time uses sensible numbering so February is 2 not 1. Another thing, a Joda-Time DateTime truly knows its assigned time zone unlike a java.util.Date which seems to have time zone but does not.

And don't forget the time zone. Otherwise you'll be getting the JVM’s default.

DateTimeZone timeZone = DateTimeZone.forID( "Asia/Singapore" );
DateTime dateTimeSingapore = new DateTime( 2014, 2, 11, 0, 0, timeZone );
DateTime dateTimeUtc = dateTimeSingapore.withZone( DateTimeZone.UTC );

java.util.Locale locale = new java.util.Locale( "ms", "SG" ); // Language: Bahasa Melayu (?). Country: Singapore.
String output = DateTimeFormat.forStyle( "FF" ).withLocale( locale ).print( dateTimeSingapore );

Dump to console…

System.out.println( "dateTimeSingapore: " + dateTimeSingapore );
System.out.println( "dateTimeUtc: " + dateTimeUtc );
System.out.println( "output: " + output );

When run…

dateTimeSingapore: 2014-02-11T00:00:00.000+08:00
dateTimeUtc: 2014-02-10T16:00:00.000Z
output: Selasa, 2014 Februari 11 00:00:00 SGT

Conversion

If you need to convert to a java.util.Date for use with other classes…

java.util.Date date = dateTimeSingapore.toDate();
🌐
LabEx
labex.io › tutorials › java-how-to-initialize-dates-in-java-time-api-419367
How to initialize dates in Java time API | LabEx
Learn essential techniques for creating, manipulating, and initializing dates using Java Time API with practical examples and best practices for modern Java development.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-simpledateformat-java-date-format
Master Java Date Formatting: SimpleDateFormat & DateFormat Guide | DigitalOcean
December 20, 2024 - Master Java date and time formatting with SimpleDateFormat and DateFormat. Learn locale-based patterns and parsing techniques to enhance your java applications!
🌐
Baeldung
baeldung.com › home › java › java dates › add hours to a date in java
Add Hours to a Date in Java | Baeldung
January 8, 2024 - However, note that it’s always recommended to use the new DateTime API for all applications on Java 8 or higher versions.
🌐
The Coding Forums
thecodingforums.com › archive › archive › java
new java.util.Date(0) | Java | Coding Forums
April 18, 2004 - If you want to produce a representation in a possibly non-local time zone, use java.text.DateFormat and set its time zone explicitly, e.g.: Date d = new Date(0); System.out.println("toString: " + d); DateFormat df = DateFormat.getDateTimeInstance(); ...
🌐
Baeldung
baeldung.com › home › java › java dates › convert string to date in java
Convert String to Date in Java | Baeldung
March 26, 2025 - However, when we print the Date object directly, it will always be printed with the Java default system time zone. In this final example, we’ll look at how to format a date while adding the time zone information: SimpleDateFormat formatter = new SimpleDateFormat("dd-M-yyyy hh:mm:ss a", Locale.ENGLISH); formatter.setTimeZone(TimeZone.getTimeZone("America/New_York")); String dateInString = "22-01-2015 10:15:55 AM"; Date date = formatter.parse(dateInString); String formattedDateString = formatter.format(date);
🌐
Tutorialspoint
tutorialspoint.com › home › java › java date and time
Java Date and Time
September 1, 2008 - Learn about Java Date and Time API, its classes, methods, and how to manipulate dates and times effectively in your Java applications.
🌐
Coderanch
coderanch.com › t › 401987 › java › create-date-object-current-date
How to create a date object which contain current date (Beginning Java forum at Coderanch)
January 9, 2006 - ... Hey, you guys sound really mean to this poor person...lol, anyways i would do what they said, if you wanted to see the current date in a readable manner, you would do something like: Date now= new Date()//to get a stamp of the current date System.out.println("The current date and time ...
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Calendar.html
Calendar (Java Platform SE 8 )
October 20, 2025 - Converts the current millisecond time value time to calendar field values in fields[]. This allows you to sync up the calendar field values with a new time that is set for the calendar. The time is not recomputed first; to recompute the time, then the fields, call the complete() method.
🌐
Coderanch
coderanch.com › t › 748511 › java › display-date-time-Java
How do you display date and time in Java? (Beginning Java forum at Coderanch)
January 4, 2022 - Most Java developers these days uses tools like Maven to manage this sort of thing, so if it's a beginner exercise I would just recommend giving up and trying a new project rather than going down that rabbit hole. ... Try this out. It works for me. First import the Date class and create a new Date object, I just use date.
🌐
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 - Yes, it is misnamed (but then again many things are and the Javadoc opens by saying clearly what Date is), it is mutable (but sometimes that is handy if you really need an object and you believe the tales that there is still (to this day) a cost involved with object creation – albeit negligible – except if you are into low latency, no jitter type of stuff), it can return 61 from the getSeconds() method (but that method has been in-your-face deprecated since the yearly days of Java, never seen the method used) and the toString() method does some weird woodo (but I never seen anyone use it, except for debug output) .. and all these things may of course add up on you. However, the truth of the matter is that while Date may be a stumbling block for newbies, if you understand what it is, then I don’t see any reason to exchange java.util.Date for java.time.Instant in existing code.
🌐
Baeldung
baeldung.com › home › java › java dates › migrating to the java date time api
Migrating to the Java Date Time API | Baeldung
October 13, 2023 - In this tutorial you will learn how to refactor your code in order to leverage the new Date Time API introduced in Java 8.
🌐
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 · 中文 – 简体