Converting Java Date to OffsetDateTime 1. Introduction In this tutorial, we learn about the difference between Date and OffsetDateTime. We also learn how to convert from one to the other. 2. Difference between Date and OffsetDateTime OffsetDateTime was introduced in JDK 8 as a modern alternative to java.util.Date. OffsetDateTime is a… Continue Reading java-convert-date-to-offsetdatetime

Converting Between LocalDate and XMLGregorianCalendar 1. Overview In this quick tutorial, we’ll discuss LocalDate and XMLGregorianCalendar and provide examples of converting between the two types. 2. XMLGregorianCalendar The XML Schema standard defines clear rules for specifying dates in XML format. In order to use this format, the Java class XMLGregorianCalendar,… Continue Reading java-localdate-to-xmlgregoriancalendar

RegEx for matching Date Pattern in Java 1. Introduction Regular expressions are a powerful tool for matching various kinds of patterns when used appropriately. In this article, we’ll use java.util.regex package to determine whether a given String contains a valid date or not. For an introduction to regular expressions, refer… Continue Reading java-date-regular-expressions

A Guide to SimpleDateFormat 1. Introduction In this tutorial, we’ll be taking an in-depth tour of the SimpleDateFormat class. We’ll take a look at simple instantiation and formatting styles as well as useful methods the class exposes for handling locales and time zones. Now, before getting started, let’s keep in mind SimpleDateFormat is not… Continue Reading java-simple-date-format

Get the Current Date, Time and Timestamp in Java 8 1. Introduction This quick article describes how we may get the current date, current time and current time stamp in Java 8. 2. Current Date First, let’s use java.time.LocalDate to get the current system date: LocalDate localDate =; To… Continue Reading current-date-time-and-timestamp-in-java-8