Package org.kiwiproject.time
Class KiwiDates
- java.lang.Object
-
- org.kiwiproject.time.KiwiDates
-
public class KiwiDates extends Object
The original JDK 1.0Dateclass leaves, ahem, much to be desired, but there are still (unfortunately) many classes, interfaces, and libraries that use it and probably won't be changed soon or ever. KiwiDate contains some utilities to convertInstantobjects toDateobjects shifted by some amount of time, for example if you need a Date that is 30 minutes from a givenInstant.If you have a choice, you should always prefer the Java 8 date/time APIs (e.g.
Instant,LocalDateTime,ZonedDateTime) in thejava.timepackage over using the legacyDate. But if you need to convert instants to dates, then this will help.Functionally this is just a Date wrapper for
KiwiInstants.
-
-
Constructor Summary
Constructors Constructor Description KiwiDates()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DatedateFrom(Instant instant)Return theDateconverted frominstant.static DatedateFromInstantMinusDays(Instant instant, long days)static DatedateFromInstantMinusHours(Instant instant, long hours)static DatedateFromInstantMinusMinutes(Instant instant, long minutes)static DatedateFromInstantMinusMonths(Instant instant, long months)static DatedateFromInstantMinusYears(Instant instant, long years)static DatedateFromInstantPlusDays(Instant instant, long days)static DatedateFromInstantPlusHours(Instant instant, long hours)static DatedateFromInstantPlusMinutes(Instant instant, long minutes)static DatedateFromInstantPlusMonths(Instant instant, long months)static DatedateFromInstantPlusYears(Instant instant, long years)
-
-
-
Method Detail
-
dateFrom
public static Date dateFrom(Instant instant)
Return theDateconverted frominstant.- Parameters:
instant- theInstantto convert- Returns:
- the converted
Date - API Note:
- This is just a simple wrapper around
Date.from(Instant)and is mainly here for consistency with the other utilities provided here
-
dateFromInstantMinusMinutes
public static Date dateFromInstantMinusMinutes(Instant instant, long minutes)
-
dateFromInstantMinusHours
public static Date dateFromInstantMinusHours(Instant instant, long hours)
-
dateFromInstantMinusMonths
public static Date dateFromInstantMinusMonths(Instant instant, long months)
-
dateFromInstantMinusYears
public static Date dateFromInstantMinusYears(Instant instant, long years)
-
dateFromInstantPlusMinutes
public static Date dateFromInstantPlusMinutes(Instant instant, long minutes)
-
dateFromInstantPlusMonths
public static Date dateFromInstantPlusMonths(Instant instant, long months)
-
-