Java 8 – How to parse date with “dd MMM” (02 Jan), without year?
This example shows you how to parse a date (02 Jan) without a year specified. The pattern dd MMM is not enough; we need a DateTimeFormatterBuilder to provide a default…
Favourite tutorials for developers
Core Java is the fundamental form of Java. We use it in all Java platforms and technologies. Without going through core Java, it is impossible to advance to advanced Java. Unlike core Java, advanced Java is a specialization of the core Java in some particular domain, such as database handling, networking, and the web.
This example shows you how to parse a date (02 Jan) without a year specified. The pattern dd MMM is not enough; we need a DateTimeFormatterBuilder to provide a default…
In Java 8, we can use ChronoUnit.DAYS.between(from, to) to calculate days between two dates, for both LocalDate and LocalDateTime.
In Java 8, we can use Instant.ofEpochMilli().atZone() to convert the epoch time in milliseconds back to LocalDate or LocalDateTime
Ramadan is the 9th month of the Islamic calendar, the entire month.
In Java 8, you can use the predefined java.time.temporal.TemporalAdjusters to adjust a date or Temporal. Example to move a date to firstDayOfMonth, firstDayOfNextMonth, next Monday and etc. Example to implement…
This article shows you how to add days to the current date, using the classic java.util.Calendar and the new Java 8 date and time APIs.
This tutorial shows you how to work with java.util.Date and java.util.Calendar. Java Date Examples: Convert Date to String, Convert String to Date, Get current date time, Convert Calendar to Date.…
This article shows Java 8 and legacy date-time APIs example to check if a date is 30 days or 6 months older than the current date. We can use few…
In Java 8, we can use Period, Duration or ChronoUnit to calculate the difference between two LocalDate or LocaldateTime: 1 - Period to calculate the difference between two LocalDate, 2…
This article shows few examples to compare two dates in Java. Updated with Java 8 examples. For the legacy java.util.Date, we can use compareTo, before(), after() and equals() to compare…