I have a date with the format 2012-02-02(yyyy-MM-dd).
For example if todays date is 2012-02-02 i need to add one and a half days to it which would make it 2012-02-03 06:00:00.0.
And if i have a number of dates of the following format 2012-02-03 06:30:00.0(yyyy-MM-dd HH:MM:SS.SSS) , i need to compare if all these dates are less than,greater than or equal to the date to which one and a half days were added above.
The comparison should also take care of the hours while comparing if the dates are less than,greater than or equal or equal to the other date and time.
How do i achieve the same.
Simple arithmetic approach (faster)
SimpleDateFormat
that creates a Date
objectDate.getTime()
to return the UTC value in long
>
, <
and ==
or after()
, before()
and equals()
if you want to use Date object itselfAPI approach (slower)
add(...)
method for adding 1 and half daybefore()
, after()
and equals()
methods of CalendarIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With