Do you have a little bored using Java Util Date? Say it to do little operation using java Util Date.
example parsing String to Date, add days , add month, round Date, truncate date
ceiling date and more operation. Using standart java code we will add some code to these operation.
Now I Have a project using JDK 7, that is using some operation or calculate class java.util date and i little bored
to see boilerplate on my project and create all operation manually.
No More Code,we can do it with DateUtils. DateUtils is a part of common-lang3 library. DateUtils contains a lot of common methods considering manipulations of Dates or Calendars. Some methods require some extra explanation. The truncate, ceiling and round methods could be considered the Math.floor(), Math.ceil() or Math.round versions for dates This way date-fields will be ignored in bottom-up order. As a complement to these methods we’ve introduced some fragment-methods. With these methods the Date-fields will be ignored in top-down order. Since a date without a year is not a valid date, you have to decide in what kind of date-field you want your result, for instance milliseconds or days.
Let see the example how to use DateUtils :
And here are the results of our code snippet above:
Happy Code, Remember No More Code check your mirror to do some your jobs 😀
Visit My Repository for full code