Below is a 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 grasp.
1) 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.
2) 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.
3) 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.
4) 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.
5) 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.
6) 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.
7) 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.
8) 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.
9) 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!!
10) 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.
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 ?
Thanks.