How can I get current date in Android?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
How you get the current date in Android depends mostly on your minimum API level. On modern Android, the cleanest answer is usually java.time, especially LocalDate.now(). On older Android versions, Calendar is the fallback you can always rely on. The most important thing is to separate "current date value" from "how you want to format it for display."
Modern Android: use LocalDate or LocalDateTime
If your app targets API level 26 and above for the code path in question, java.time is the clearest API.
If you also need the current time:
These classes are immutable, easier to read than older date APIs, and much less error-prone for normal application code.
Formatting the date for the UI
Getting the current date and displaying it are different steps. Once you have a LocalDate, format it explicitly.
This makes the display rule obvious. It also avoids the common mistake of relying on whatever toString() happens to output.
Older-compatible fallback: Calendar
If you need code that works on older Android APIs without depending on newer java.time support in that path, Calendar remains the standard fallback.
The + 1 on month is important because Calendar.MONTH is zero-based. That off-by-one detail is one of the biggest reasons many Android developers prefer java.time when possible.
Java example with legacy formatting
If you want a formatted string directly using older APIs:
This works, but it mixes "current instant" and "formatting" in one step. For new code, java.time is usually easier to maintain.
Choose the right date concept
Another source of confusion is choosing the wrong type:
- use
LocalDateif you need only the calendar date - use
LocalDateTimeif you need date plus time without a zone - use
Instantor zoned types when exact cross-time-zone behavior matters
For something like "show today's date in the app," LocalDate.now() is usually the correct level of abstraction.
Common Pitfalls
The biggest mistake in old Android code is forgetting that Calendar.MONTH is zero-based. That leads to dates that look one month off.
Another issue is using Date or Calendar for new code when java.time is available and clearer.
Developers also sometimes format a date with the default locale or pattern without thinking about how the UI should really look. A date string intended for storage is not the same as a date string intended for users.
Finally, "current date" depends on time zone. If the app works across zones or server timestamps, be explicit about which zone defines "today."
One more subtle issue is testing near midnight. Code that seems correct during the day can behave differently around date boundaries, especially if background work and UI rendering happen in different zones or at slightly different times.
Summary
- On modern Android, prefer
LocalDate.now()for the current date. - Use
LocalDateTime.now()only when you also need the current time. - Use
Calendaras a fallback for older-compatible code paths. - Format dates explicitly instead of relying on
toString(). - Be careful with zero-based months and time-zone assumptions.

