Date Manipulation in Java

Hello friends,
Hope you all are doing fine.!
Today I am back again with some interesting stuff.

So let’s begin.

Sometimes we may come across a situation where we need to manipulate the date, time or year, manipulate here means we may have to add some hours in the time or add some years in the date. In other words, we are converting the date and time to some future values. The modus operandi of doing this depends on the testing which we will do with future date or time, sometimes we may need to compare the date or time to some future value or vice versa compare it with some past value. Whatever the reason be, to deal with this Java provides us with some very useful built-in functions and Classes.

Please check the example below:-



Above code illustrates the concept of date manipulation.
Please let me know for any questions or suggestions.

Also if you are looking for the long and complete Time Stamp then you can use the code as given below:-



We can use the DateFormat class if we are looking to work with the complete Time Stamp.
That’s it folks.Enjoy automating.
Automate anything, Automate everything…!!