Date & Time Handling In JAVA
While automating any web application, there might arise a situation where you might need to play around with Date and Time objects and manipulate them as per your need. Also, you may land into a situation where you need to pick dates from the UI. There are ample situations where I have used Date in all different kinds of projects. So let us understand how to achieve this in Java. Java provides an inbuilt Date class available under the java.util package, this class holds the current date and time. Also, there are other classes using which we can simply use the date. First, let's see some methods to get the current date and time in Java. Following is a snippet showing three different ways to get Date/Time in Java, which can further be used to do some other action. Following is the output based on Line Number from the above code. As per the required pattern of date+time format, we can print the date into our console or save them in a variable. Line No. 23/24 shows the easiest ...