In java, we have several classes to handle and perform date and time operations. These operations can be performed on date, time or timezone. In this guide, I have provided the links to all the tutorials and Java 8 date time API guides collection.
Java 8 Date/Time API
- java.time.LocalTime class
- java.time.LocalDate class
- java.time.LocalDateTime class
- java.time.ZoneId class
- java.time.ZonedDateTime class
- java.time.ZoneOffset class
- java.time.OffsetTime class
- java.time.OffsetDateTime class
- java.time.Year class
- java.time.YearMonth class
- java.time.MonthDay class
- java.time.Clock class
- java.time.Period class
- java.time.Duration class
- java.time.Instant class
- java.time.Month enum
- java.time.DayOfWeek enum
Following is the collection of tutorials which I have shared on Date in Java. All of these tutorials are explained with the help of examples so that it would be easy for you to understand the concept.
- How to convert String to Date in Java – It includes a user defined function which converts String to Date. Also I have shared an example java program for String to Date Conversion.
- How to convert Date to String in Java – This tutorial is a vice versa of above tutorial. Here I explained how to perform Date to String conversion in Java with the help of few examples.
- Date comparison in java – Explained with the help of a java code, which takes two dates as input (can be in different format) then it compares the date and return the result.
- Date format in Java – There are many scenarios where in we may need a date in so and so format. This post will help you to change a date in any desired format you want. Give it a try, its interesting.
- How to calculate number of days between two dates – While building a complex java code you may have faced a situation where you had to calculate number of day between two dates. This post includes a code which does this work for you so you don’t have to code yourself just have this code and play with java.
- Java date format validation – It has a java program which checks whether the format of input date is valid or not. Here you can give your own format as input, it works for all formats of date.
- Java date and timezone – How to handle time-zones while doing date operations in a java program. Also how to get output is desired timezone format.
- Days calculation from Date – Here you will learn how perform calculation in java program to get the output in number of days while the input is a date.
- How to get previous day date and next day date for a given date – You would learn how to write a code which can find out previous day date and next day date for a given input date. Its not that easy as it seems, give it a try!!
- Date difference in Java – How to calculate date difference in java for two input dates. It includes a java code which does it pretty good.
- Date parsing in java
- Java simple date format
- Java calendar class
- Compare two dates with each other in Java
- Date validation in java
The whole internet has tons of example wherein a date value is input into a “string Type” or “int type” and then using formatting classes “converted” into a Date type. Does it mean that Java has no direct capability like many other languages to take input directly into a “date” type variable using scanner class or any other type of input class. Maybe i have used other types of business development languages that allow one to input a date value into a date ‘type’ variable and validate it. Its extremely strange to me that i don’t see such examples in Java. Is there a way to do this at all in Java ? and why does it not exist anyway as a simple way to inut into Java ? And what are the different ways that i can input something in the date format as “mm/dd/yyyy” and then validate it ?