Do you absolutely have to use java.util.Date? I would thoroughly recommend that you use Joda Time or the java.time package from Java 8 instead. In particular, while Date and Calendar always represent a particular instant in time, with no such concept as "just a date", Joda Time does have a type representing this (LocalDate). Your code will be much clearer if you're able to use types which represent what you're actually trying to do.

There are many, many other reasons to use Joda Time or java.time instead of the built-in java.util types - they're generally far better APIs. You can always convert to/from a java.util.Date at the boundaries of your own code if you need to, e.g. for database interaction.

Answer from Jon Skeet on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java dates › get date without time in java
Get Date Without Time in Java | Baeldung
March 12, 2025 - In the next sections, we’ll show some common workarounds to tackle this problem. One of the most common ways to get a Date without time is to use the Calendar class to set the time to zero.
Discussions

Java program to get the current date without timestamp - Stack Overflow
But I need only the date, without a timestamp. I use this date to compare with another date object that does not have a timestamp. ... A java.util.Date object is a kind of timestamp - it contains a number of milliseconds since January 1, 1970, 00:00:00 UTC. More on stackoverflow.com
🌐 stackoverflow.com
May 11, 2010
Converting String to Time without Date in Java - Stack Overflow
You can't have a Date without the calendar date parts. That's a simple fact of what Date represents: The class Date represents a specific instant in time, with millisecond precision. ... represent[s] the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT. You can use LocalTime in java... More on stackoverflow.com
🌐 stackoverflow.com
May 23, 2017
Java String to Date without time - Stack Overflow
I'm taking a class in Java and I need to convert a string to a date format (dd/MM/yyyy). I have been using the SimpleDateFormat to format my input, but it is showing the time, timezone and day of the More on stackoverflow.com
🌐 stackoverflow.com
What's are best practices when dealing with dates, without time-of-day?
4 is the usual standard. More on reddit.com
🌐 r/AskProgramming
6
1
May 19, 2022
🌐
W3Docs
w3docs.com › java
How do I get a Date without time in Java?
To get a java.util.Date object with the time set to 00:00:00 (midnight), you can use the toInstant() method to convert a LocalDate object to an Instant, and then use the atZone() method to convert the Instant to a ZonedDateTime object, and finally use the toLocalDate() method to extract the LocalDate from the ZonedDateTime.
🌐
Codemia
codemia.io › knowledge-hub › path › how_do_i_get_a_date_without_time_in_java
How do I get a Date without time in Java?
2 weeks ago - Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
w3resource
w3resource.com › java-exercises › datetime › java-datetime-exercise-40.php
Java - Display current date, time without time, date
Write a Java program to display only the time component of the current date-time using formatting techniques.
🌐
Medium
medium.com › @alxkm › how-to-work-with-dates-in-java-a-complete-guide-203b7e657648
How to Work with Dates in Java: A Complete Guide | by Alex Klimenko | Medium
August 9, 2025 - Part of the modern Java Time API (java.time package, introduced in Java 8). Represents a date without time and without time zone-ideal for birthdays, holidays, or any date-only use cases.
🌐
CodeSpeedy
codespeedy.com › home › how to get date without time in java
How To Get Date without Time in Java - CodeSpeedy
September 29, 2019 - In this program, we will be getting the date without the time class. Initially, we will be importing “java.util.date” package.
🌐
Roy Tutorials
roytuts.com › home › java › compare date without time in java
Compare Date Without Time In Java - Roy Tutorials
November 15, 2023 - In Java 8 you can easily compare two dates without having time because Java 8 Date API provides LocalDate final class that gives you only date part.
Find elsewhere
🌐
Quora
quora.com › How-can-I-print-current-time-of-the-system-without-date-in-Java
How to print current time of the system without date in Java - Quora
Answer (1 of 2): Try this. If d[3] doesnt print it, try d[4] or d[2] [code]public static void main(String args[]) { java.util.Date date = new java.util.Date(); String[] d = date.toString().split("\\s+"); System.out.println(d[3]); } [/code]
Top answer
1 of 16
39

A java.util.Date object is a kind of timestamp - it contains a number of milliseconds since January 1, 1970, 00:00:00 UTC. So you can't use a standard Date object to contain just a day / month / year, without a time.

As far as I know, there's no really easy way to compare dates by only taking the date (and not the time) into account in the standard Java API. You can use class Calendar and clear the hour, minutes, seconds and milliseconds:

Calendar cal = Calendar.getInstance();
cal.clear(Calendar.HOUR_OF_DAY);
cal.clear(Calendar.AM_PM);
cal.clear(Calendar.MINUTE);
cal.clear(Calendar.SECOND);
cal.clear(Calendar.MILLISECOND);

Do the same with another Calendar object that contains the date that you want to compare it to, and use the after() or before() methods to do the comparison.

As explained into the Javadoc of java.util.Calendar.clear(int field):

The HOUR_OF_DAY, HOUR and AM_PM fields are handled independently and the the resolution rule for the time of day is applied. Clearing one of the fields doesn't reset the hour of day value of this Calendar. Use set(Calendar.HOUR_OF_DAY, 0) to reset the hour value.

edit - The answer above is from 2010; in Java 8, there is a new date and time API in the package java.time which is much more powerful and useful than the old java.util.Date and java.util.Calendar classes. Use the new date and time classes instead of the old ones.

2 of 16
11

You could always use apache commons' DateUtils class. It has the static method isSameDay() which "Checks if two date objects are on the same day ignoring time."

static boolean isSameDay(Date date1, Date date2) 
🌐
W3Schools
w3schools.com › java › java_date.asp
Java Date and Time
The following example will remove both the "T" and nanoseconds from the date-time: import java.time.LocalDateTime; // Import the LocalDateTime class import java.time.format.DateTimeFormatter; // Import the DateTimeFormatter class public class Main { public static void main(String[] args) { LocalDateTime myDateObj = LocalDateTime.now(); System.out.println("Before formatting: " + myDateObj); DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss"); String formattedDate = myDateObj.format(myFormatObj); System.out.println("After formatting: " + formattedDate); } }
🌐
Tutorjoes
tutorjoes.in › Java_example_programs › display_current_date_without_time_and_current_time_without_date_in_java
Write a Java program to display current date without time and current time without date
import java.time.LocalDate; import java.time.LocalTime; import java.util.Date; class Current_DateTime { public static void main(String[] args){ LocalDate d = LocalDate.now(); System.out.println("Current date = " + d); LocalTime t = LocalTime.now(); System.out.println("Current time = " + t); } }
🌐
Coderanch
coderanch.com › t › 389201 › java › Time-date
Time without date. Help! (Beginning Java forum at Coderanch)
July 15, 2001 - I have managed to return the full date/time value in html (i.e. including day, date, year, timezone), but all I actually want is the time of day, not the day/date/year etc. So, for example, I can create an html document with: "Sun Jul 02 23:00:00 GMT+01:00 2001" When all I actually want to display is: "23:00" Can anyone help me? Some sample code would be really useful. Thanks in advance, James ... Hi, James. Try something like this: Running this code returns but of course, the way I set it up, the specific value you see will depend on when you run it. For more on java.text.SimpleDateFormat, i.e., what characters you can pass in its constructor's String, click here.
🌐
Reddit
reddit.com › r/askprogramming › what's are best practices when dealing with dates, without time-of-day?
r/AskProgramming on Reddit: What's are best practices when dealing with dates, without time-of-day?
May 19, 2022 -

What is best practice when dealing with date values without time, in JavaScript? My concern is subtle off-by-one bugs caused by local Time Zone (TZ) offset (e.g. +5 hours), when doing date math.

JavaScript's built-in Date type represents a date and time not just the date. Internal representation is an integer of microseconds since 1970-01-01 00:00:00 UTC. Other languages, like Python, have separate Date and DateTime types. Java 8 introduced LocalDate.

You also have things like: new Date('5/18/2020') is local TZ (in US), but new Date('2022-05-18') is UTC. Same with Date.parse(string). And the time zone on most servers in UTC, whereas on the browser side the time zone will vary.

The date values will be used for simple date math in code and will be stored in a SQL database.

Possibilities:

  1. Use the an alternate type like integer value, of milliseconds or days (since 1970-01-01), or string in YYYYMMDD format.

  2. This was combined with #1

  3. Use Date ignoring time (as 00:00 local TZ). Convert from/to UTC when reading/writing to database

  4. Use Date with time as 00:00 UTC. Have to be careful not to mix with Date values in local TZ (e.g. now = new Date())

  5. Use Date in local TZ, but convert to UTC when read/writing to database. This is a variant of #3.

  6. Create a LocalDate class that enforces midnight.

  7. Use a library. js-joda has LocalDate.

I am leaning towards #3 and #6. Some code I am writing:

class LocalDate extends Date {
  // Error if time isn't midnight local TZ
  // Do not accept string in ISO format
  constructor(date?: Date|number|string)

  // Convert to 00:00 UTC
  // To be used before write to database
  toUtc(): Date

  // Only return date.  Also affects toJSON()
  toISOString(): string

  // Returns today's date at 00:00 Local TZ
  static today(): LocalDate
  // Set time to midnight local TZ, without error check.
  static fromDateTime(date: Date|number): LocalDate
  // Convert to local TZ.  Error if not 00:00 UTC.
  static fromUtc(date: Date|number): LocalDate
}

UPDATE:

Various edits.

🌐
Reintech
reintech.io › blog › java-date-and-time-api
Java date and time API: Working with dates, times, and durations | Reintech media
April 18, 2023 - The LocalTime class in Java represents time without any date or timezone information. It's a part of the Java Date and Time API, providing functionality for time manipulation.
🌐
Medium
medium.com › @AlexanderObregon › beginners-guide-to-handling-date-and-time-in-java-cc2fcc5b13f1
Beginner’s Guide to Handling Date and Time in Java
March 19, 2024 - Let's dive into the key classes introduced by the java.time package and understand their use cases: LocalDate represents a date without time of day or timezone information, such as 2024-04-11.
🌐
Intellipaat
intellipaat.com › home › blog › java date and time
Java Date and Time: LocalDate, LocalDateTime, Instant
October 17, 2025 - The LocalDate class was introduced in Java 8, as a part of the java.time package that represents a date without any time or timezone information (just year, month, and day) is the standard method of capturing dates as needed.