Category: Date and Time
Converting a String into a Date in Java
This tutorial shows how to convert a java.lang.String into a java.util.Date. We can convert a String into a Date using the parse() method of the DateFormat and SimpleDateFormat classes. // from java.lang.String into java.util.Date...
Getting Current Date and Time in Java
This tutorial shows how to get the current date and time in Java. The standard Java classes we can use are java.util.Date, java.util.Calendar and the new java 8 java.time.LocalDateTime and java.time.ZonedDateTime. You could also...
Calculate Age from date of birth in Java
This tutorial demonstrates how to calculate the age from a birth date in Java. Something trivial as calculating the age, was daunting before Joda Time and Java 8. Let’s list the options you have...
How to parse a date in Java
In this tutorial we will show you how to parse a date in Java. To parse a date the JDK provides a SimpleDateFormat class. You can either define your own custom date format strings...
How to format Date in Java
In this tutorial we will show you how to format date in Java. To format a date the JDK provides a SimpleDateFormat class. You can either define your own custom date format strings or...
Get Last Day Of The Month From Date Object
In this example we show you how you can get the last day of the month. Most of the time we use a java.util.Date Object to represent a Date. We can use the java.util.Calendar...
Get The First Day Of The Month From Date Object
In this example we show you how you can get the first day of the month. Most of the time we use a java.util.Date Object to represent a Date. We can use the java.util.Calendar...
Calculate Relative Time also known as “Time Ago” In Java
Time Ago Generation Days, Hours, Seconds Here is an example of how you can calculate relative time also know as “time ago” in java. This will return the time difference between two dates in...
Correct Way of Calculating Elapsed Time in Java
Calculating Elapsed Time The main reason why you want to know the elapsed time of the method executions is to identify bottlenecks and long running methods, or simply if you want to let your...