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
🌐
W3Docs
w3docs.com › java
How do I get a Date without time in Java?
import java.time.*; import java.util.*; ... with time set to midnight) Alternatively, you can use the truncatedTo() method of the LocalDateTime class to truncate the time to midnight....
🌐
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.
🌐
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
🌐
Techie Delight
techiedelight.com › home › java › how to get time without date in java
How to get time without date in Java | Techie Delight
December 24, 2021 - Java · Updated 3 years agoDecember 24, 2021 · This post will discuss how to get time without a date in Java. Since JDK 1.8, you can use the java.time package that offers standard API for dates, times, instants, and durations. It contains java.timeLocalTime class, which represents a time without a time-zone.
🌐
CodeSpeedy
codespeedy.com › home › get the current date without time in java
Get the current date without time in Java - CodeSpeedy
December 11, 2021 - By using the Calendar class the time can be set to zero, that’s how we can get a clean date without time. Let’s do a program applying this method: import java.util.Calendar; class GetCurDate { public static void main(String[] args) { Calendar ...
🌐
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.
Find elsewhere
🌐
Joda
joda.org › joda-time › key_partial.html
Joda-Time – Java date and time API - Partial
Within Joda-Time a partial is represented by the ReadablePartial interface. There are six implementations of the interface provided: LocalDate - An immutable implementation that represents a date without a time or time zone.
🌐
Mkyong
mkyong.com › home › java › java – how to get current date time
Java - How to get current date time - Mkyong.com
March 22, 2021 - DateFormat dateFormat = new ... 16:37:15 · For the java.time.LocalDate, uses LocalDate.now() to get the current date without a time-zone, and format it with the DateTimeFormatter....
🌐
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]
🌐
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); } }
🌐
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.
🌐
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.
🌐
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); } }
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 326440 › getting-time-without-date
java - Getting time without date | DaniWeb
November 21, 2010 - I know I can convert it into a String then get the substring of the time, but if I do that i will have to convert it to date again when I am going to use it. Any help would be appreciated I supplied the method below. public Date curBookingEndTime(){ //String date= dateTextF.getText(); Calendar cal= Calendar.getInstance(); DateFormat format= new SimpleDateFormat("hh:mm"); java.util.Date dateUtil2 = new java.util.Date(); Date calcuDate=null; try { dateUtil2 = format.parse(selected); System.out.println("selected "+ selected); } catch (ParseException ex) { Logger.getLogger(MainFrame.class.getName(
🌐
Mkyong
mkyong.com › home › java › how to compare dates in java
How to compare dates in Java - Mkyong.com
March 26, 2021 - java.time.LocalDate – date without time, no time-zone.