How do I get a Date without time in Java?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
In modern Java, the best way to represent a date without a time is to use LocalDate. It exists specifically for year-month-day values and avoids the confusion that comes from java.util.Date, which always represents a point in time. If you are working with newer Java code, the real answer is usually not "strip the time from Date" but "use the right type for a date-only value."
Use LocalDate for Date-Only Values
LocalDate is part of the java.time API introduced in Java 8. It has no hour, minute, second, or time zone component.
This prints a value like 2026-03-11 and does not carry any time-of-day state.
That is the cleanest representation for birthdays, due dates, calendar dates, and other date-only concepts.
Why java.util.Date Is Different
java.util.Date is not a date-only type. It represents an instant, which means it always includes time, even if formatting hides that fact.
This distinction matters because many bugs come from storing a date-only business concept in a timestamp type and then accidentally shifting it through time zones.
If you have control over the model, prefer LocalDate instead of trying to zero out a Date.
Convert a Legacy Date to LocalDate
If older APIs still return java.util.Date, convert it explicitly.
This is the usual bridge between old and new APIs.
If You Truly Need a Date at Midnight
Sometimes you still must pass a java.util.Date to a legacy API. In that case, you can derive a midnight timestamp from a LocalDate.
Be careful here: this is still a timestamp. It only looks like a date-only value because you chose midnight in one time zone.
Parsing a Date String Without Time
If the input is text such as 2026-03-11, parse it directly into LocalDate instead of parsing a full date-time first.
This keeps the value date-only from the beginning and avoids unnecessary conversions.
Formatting a Date Without Time
If the requirement is display rather than storage, format the LocalDate directly.
This prints only the date portion because the underlying type itself has no time.
Common Pitfalls
- Using
java.util.Datewhen the business concept is really date-only. - Zeroing out time fields on a timestamp and assuming it is now a true date-only type.
- Ignoring time zones when converting between
DateandLocalDate. - Formatting away the time and assuming the stored value no longer contains one.
- Mixing legacy and modern date APIs without explicit conversion.
Summary
- In modern Java, use
LocalDatefor a date without time. - '
java.util.Datealways represents a point in time, not a pure date.' - Convert legacy
Datevalues toLocalDatewhen possible. - Only create a midnight
Datewhen a legacy API forces you to. - Keep storage type and business meaning aligned to avoid date-time bugs.
Related reading
- How do I get my Maven Integration tests to run
- How do I get the file extension of a file in Java?
- How do I get the size of a java.sql.ResultSet?
- How do I handle RabbitMQ Consumer Cancellation Notification when using Spring ChannelAwareMessageListener
- How do I hide .class files from the Open Resource dialog in Eclipse?
- How do i implement Headers Exchange in RabbitMQ using Java?
- How do I implement task prioritization using an ExecutorService in Java 5?
- How do I import the javax.servlet / jakarta.servlet API in my Eclipse project?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.