Java returns the current date and time from the static now() method of the java.time classes, such as LocalDate.now(), LocalDateTime.now() or Instant.now(), which read the system clock and return an immutable object for that moment. The class we pick decides what we get back, only the date, only the time, both, or a moment with a time zone.
We read the current date and time to stamp orders and log entries, to show today’s date on a screen, and to check business rules such as an expired coupon or a booking that starts too soon.
The following example calls now() on each class. The values change on every run, so the comments describe what each line returns.
LocalDate today = LocalDate.now(); // current date in the JVM default zone
LocalTime time = LocalTime.now(); // current time of day in the default zone
LocalDateTime dateTime = LocalDateTime.now(); // current date and time, no zone stored
ZonedDateTime paris = ZonedDateTime.now(ZoneId.of("Europe/Paris")); // current date and time in Paris
Instant instant = Instant.now(); // current moment in UTC
Notice that every now() call without an argument uses the default time zone of the JVM. We first compare what each class returns for one fixed moment. After that, we read the clock in a chosen zone, format the result, make the code testable with a Clock, and pass the current time to older APIs.
1. What Each java.time Class Returns From the Clock
All the java.time classes read the same system clock, so their now() methods return the same moment in different shapes. An Instant is a point on the UTC timeline. The local classes take that point, convert it to a time zone and keep only the fields we ask for.

To see real values, we pass a fixed Clock to now(). The clock always returns 08:15:30 UTC on October 10, 2026, and its zone is Asia/Kolkata, which is 5 hours 30 minutes ahead of UTC.
Clock clock = Clock.fixed(Instant.parse("2026-10-10T08:15:30Z"), ZoneId.of("Asia/Kolkata"));
Instant instant = Instant.now(clock); // 2026-10-10T08:15:30Z
ZonedDateTime zoned = ZonedDateTime.now(clock); // 2026-10-10T13:45:30+05:30[Asia/Kolkata]
OffsetDateTime offset = OffsetDateTime.now(clock); // 2026-10-10T13:45:30+05:30
LocalDateTime dateTime = LocalDateTime.now(clock); // 2026-10-10T13:45:30
LocalDate today = LocalDate.now(clock); // 2026-10-10
LocalTime time = LocalTime.now(clock); // 13:45:30
The table sums up when each class fits. The local classes drop the zone after the conversion, so a LocalDateTime cannot tell us later which moment it was.
| Class | What now() returns | Typical use |
|---|---|---|
| LocalDate | Today’s date, such as 2026-10-10 | Birthdays, due dates, daily reports |
| LocalTime | The time of day, such as 13:45:30 | Opening hours, alarms |
| LocalDateTime | Date and time without a zone | Values shown to one user in one place |
| ZonedDateTime | Date and time with a zone such as Asia/Kolkata | Meetings and schedules across zones |
| OffsetDateTime | Date and time with a UTC offset such as +05:30 | REST APIs and database columns with an offset |
| Instant | A moment in UTC, such as 2026-10-10T08:15:30Z | Timestamps in logs, events and databases |
The no-argument now() of LocalDate, LocalTime, LocalDateTime, ZonedDateTime and OffsetDateTime uses Clock.systemDefaultZone(). Only Instant.now() does not depend on the default zone. For the moment as a number of milliseconds, see the article on the current timestamp in Java.
2. Reading the Clock in a Given Time Zone
The default zone comes from the operating system or from the -Duser.timezone option, and it is often UTC on cloud servers and in Docker containers. Code that calls LocalDate.now() on such a server gets the UTC date, not the date of the user or the business.
For example, a food delivery app in India builds a “today’s orders” report. At 02:00 in India it is still the previous evening in UTC, so a report that calls LocalDate.now() on a UTC server shows yesterday’s orders.
Clock serverClock = Clock.fixed(Instant.parse("2026-10-09T20:30:00Z"), ZoneOffset.UTC);
LocalDate serverDate = LocalDate.now(serverClock); // 2026-10-09
LocalDate indiaDate = LocalDate.now(serverClock.withZone(ZoneId.of("Asia/Kolkata"))); // 2026-10-10
LocalTime indiaTime = LocalTime.now(serverClock.withZone(ZoneId.of("Asia/Kolkata"))); // 02:00
When the date or the time depends on a place, we pass the ZoneId of that place to now() instead of trusting the default zone. For UTC, we pass ZoneOffset.UTC. Zone IDs such as Europe/Paris also follow daylight saving time, whereas a fixed offset such as +02:00 does not.
ZonedDateTime tokyo = ZonedDateTime.now(ZoneId.of("Asia/Tokyo")); // current date and time in Tokyo
LocalDate utcDate = LocalDate.now(ZoneOffset.UTC); // current date in UTC
LocalTime newYorkTime = LocalTime.now(ZoneId.of("America/New_York")); // current time of day in New York
ZoneId jvmZone = ZoneId.systemDefault(); // the zone the no-argument now() uses
A wrong zone ID such as ZoneId.of(“India”) throws a ZoneRulesException, and a malformed one throws a DateTimeException. The list of valid IDs is in the article on supported zone IDs and offsets, and the JVM default can be changed as shown in setting the JVM time zone.
3. Printing the Current Date and Time in a Custom Format
The toString() method of each class prints the ISO-8601 format, such as 2026-10-10T13:45:30. It leaves out the seconds and the fraction when they are zero, so the length of the text changes from call to call. For a fixed layout, we format the value with a DateTimeFormatter.
Clock clock = Clock.fixed(Instant.parse("2026-10-10T08:15:30Z"), ZoneId.of("Asia/Kolkata"));
LocalDateTime dateTime = LocalDateTime.now(clock);
String european = dateTime.format(DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm")); // "10-10-2026 13:45"
String us = dateTime.format(DateTimeFormatter.ofPattern("MM/dd/yyyy hh:mm a", Locale.US)); // "10/10/2026 01:45 PM"
String withZone = ZonedDateTime.now(clock).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z", Locale.US)); // "2026-10-10 13:45:30 IST"
String iso = ZonedDateTime.now(clock).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); // "2026-10-10T13:45:30+05:30"
The pattern letters HH print the hour from 00 to 23, whereas hh prints it from 01 to 12 and needs the a marker, otherwise 13:45 and 01:45 look the same. The articles on date formatting and the 12-hour format explain all the pattern letters.
4. Making Code That Calls now() Testable
Code that calls LocalDate.now() inside a business method returns a different result every day, so a unit test cannot check it. The fix is to pass a Clock into the class and call now(clock). In production, we pass Clock.systemUTC() or Clock.system(zone), and in tests a fixed clock.
For example, a coupon service decides whether a discount code is still valid. The coupon ends at the end of its last day in the shop’s zone.
record Coupon(String code, LocalDate lastDay) {}
class CouponService {
private final Clock clock;
CouponService(Clock clock) {
this.clock = clock;
}
boolean isValid(Coupon coupon) {
LocalDate today = LocalDate.now(clock);
return !today.isAfter(coupon.lastDay());
}
}
Coupon coupon = new Coupon("SAVE10", LocalDate.of(2026, 10, 10));
Clock lastDay = Clock.fixed(Instant.parse("2026-10-10T18:00:00Z"), ZoneId.of("Europe/Berlin"));
boolean valid = new CouponService(lastDay).isValid(coupon); // true
Clock nextDay = Clock.offset(lastDay, Duration.ofHours(6));
boolean expired = new CouponService(nextDay).isValid(coupon); // false
CouponService production = new CouponService(Clock.system(ZoneId.of("Europe/Berlin"))); // reads the real clock
The Clock.offset() method moves a clock forward, here from 20:00 to 02:00 the next day in Berlin, so the test covers the day change without waiting. Since Java 17, code that needs only the instant can depend on the smaller InstantSource interface, which Clock implements.
5. Passing the Current Time to Older APIs
Some libraries and JDBC drivers still take a java.util.Date, a Calendar or a java.sql.Timestamp. We still read the clock with java.time and convert the result at the call, so the rest of the code stays on the modern classes.
Instant now = Instant.parse("2026-10-10T08:15:30Z");
Date legacyDate = Date.from(now); // the same moment as a java.util.Date
Instant back = legacyDate.toInstant(); // 2026-10-10T08:15:30Z
GregorianCalendar calendar = GregorianCalendar.from(ZonedDateTime.ofInstant(now, ZoneId.of("Asia/Kolkata")));
int hour = calendar.get(Calendar.HOUR_OF_DAY); // 13
java.sql.Timestamp timestamp = java.sql.Timestamp.from(now); // the same moment for JDBC
A Date holds only an instant, and its toString() prints that instant in the default zone, which is why new Date() seems to have a time zone. The conversions in both directions are in the articles on LocalDate and Date and LocalDateTime and Date.
6. Current Date and Time FAQs
Time zones, testing and the right class for the job come up right after the first call to now().
6.1. How do we get the current date without the time?
We call LocalDate.now(), or LocalDate.now(zone) for a specific place. A LocalDate has no time part, so its toString() prints only a value such as 2026-10-10.
6.2. How do we get the current date and time in UTC?
We pass ZoneOffset.UTC to the class we need, or we call Instant.now(), which is always in UTC.
OffsetDateTime utcNow = OffsetDateTime.now(ZoneOffset.UTC); // current date and time with offset Z
LocalDateTime utcLocal = LocalDateTime.now(ZoneOffset.UTC); // current UTC date and time, no zone stored
Instant utcInstant = Instant.now(); // current moment, printed with a Z
6.3. Why does LocalTime.now() print a different number of fraction digits?
LocalTime.toString() prints the fraction in groups of three digits and drops trailing zeros, so a run can print 13:45:30.123 and the next one 13:45:30.123456. The precision of the clock depends on the operating system. On Linux, Java 25 reads the clock in nanoseconds, whereas Java 8 stopped at milliseconds. We format with a pattern such as HH:mm:ss when the layout must stay the same.
6.4. Is LocalDateTime.now() the same on every server?
No. It converts the clock to the default zone of each JVM, so two servers in different zones return different local values for the same moment. For values that leave the JVM, such as database rows and API responses, we store an Instant or an OffsetDateTime.
6.5. Should we still use new Date() or Calendar.getInstance()?
No, not in new code. Both are mutable and mix the moment with the default zone. We call the java.time methods and convert with Date.from(instant) only where an old API needs a Date.
7. Conclusion
The now() method of LocalDate, LocalTime, LocalDateTime, ZonedDateTime, OffsetDateTime and Instant returns the current date, time or moment. All of them except Instant depend on a time zone, so we pass a ZoneId when the result depends on a place.
We format the result with a DateTimeFormatter pattern, inject a Clock to make the code testable, and convert to Date or Timestamp only at the edge of old APIs. We cover related tasks, such as adding days and comparing dates, in the Java date and time guide.
8. References
- Clock (Java SE 25 API)
- LocalDate (Java SE 25 API)
- ZoneId (Java SE 25 API)
- InstantSource (Java SE 25 API)
- Oracle Java Tutorial, Date Time
Happy Learning !!
The code doesn’t work, probably because you don’t mention the libraries that I need to import.
There is no need to import any library. What exactly is not working?