FnDate is a function hub class containing a lot of static methods to work with Date objects. Those static methods return functions that take a Date object either as its input or output (depending on the function). It includes conversions to String, to Date and adding days to a Date among others.
Function name | Type | Params | Description |
---|---|---|---|
add | Function<Date,Date> | int calendarField int amount | Modifies a Date by adding a positive or negative amount to one of its fields. Fields are specified by means of java.util.Calendar constants, like FnDate.add(Calendar.DAY_OF_MONTH, 1). |
addDays | Function<Date,Date> | int amount | Modifies a Date by adding a positive or negative amount to one the "day" property (java.util.Calendar.DATE). |
addHours | Function<Date,Date> | int amount | Modifies a Date by adding a positive or negative amount to one the "hour" property (java.util.Calendar.HOUR). |
addMilliseconds | Function<Date,Date> | int amount | Modifies a Date by adding a positive or negative amount to one the "millisecond" property (java.util.Calendar.MILLISECOND). |
addMinutes | Function<Date,Date> | int amount | Modifies a Date by adding a positive or negative amount to one the "minutes" property (java.util.Calendar.MINUTES). |
addMonths | Function<Date,Date> | int amount | Modifies a Date by adding a positive or negative amount to one the "month" property (java.util.Calendar.MONTH). |
addWeeks | Function<Date,Date> | int amount | Modifies a Date by adding a positive or negative amount to one the "week" property (java.util.Calendar.WEEK). |
addYears | Function<Date,Date> | int amount | Modifies a Date by adding a positive or negative amount to one the "year" property (java.util.Calendar.YEAR). |
after | Function<Date,Boolean> | Date date | Determines whether the target Date represents a moment in time after the Date specified as a parameter. |
before | Function<Date,Boolean> | Date date | Determines whether the target Date represents a moment in time before the Date specified as a parameter. |
eq | Function<Object,Boolean> | Date object | Determines whether the target object and the specified object are equal by calling the equals method on the target object. |
fieldIntegerArrayToDate | Function<Integer[], Date> | Converts an Integer[] containing the components of a date to a java.util.Date object. The target array can contain the following combinations of elements, in the specified order:
| |
fieldIntegerListToDate | Function<List<Integer>, Date> | Converts a List<Integer> containing the components of a date to a java.util.Date object. The target list can contain the following combinations of elements, in the specified order:
| |
fieldStringArrayToDate | Function<String[], Date> | Converts a String[] containing the components of a date to a java.util.Date object. The target array can contain the following combinations of elements, all of them in numeric format, in the specified order:
| |
fieldStringListToDate | Function<List<String>, Date> | Converts a List<String> containing the components of a date to a java.util.Date object. The target list can contain the following combinations of elements, all of them in numeric format, in the specified order:
| |
isNotNull | Function<Object,Boolean> | Determines whether the target object is null or not. | |
isNull | Function<Object,Boolean> | Determines whether the target object is null or not. | |
notEq | Function<Object,Boolean> | Date object | Determines whether the target object and the specified object are NOT equal by calling the equals method on the target object. |
round | Function<Date,Date> | int calendarField | Rounds the target Date, setting the specified field as the most significant field. Based on org.apache.commons.lang.time.DateUtils.round(). |
set | Function<Date,Date> | int calendarField int value | Modifies a Date by setting one of its to the specified value. Fields are specified by means of java.util.Calendar constants, like FnDate.set(Calendar.DAY_OF_MONTH, 12). |
setDay | Function<Date,Date> | int value | Modifies a Date by setting the "day" property (java.util.Calendar.DATE) to the specified value. |
setHour | Function<Date,Date> | int value | Modifies a Date by setting the "hour" property (java.util.Calendar.HOUR) to the specified value. |
setMillisecond | Function<Date,Date> | int value | Modifies a Date by setting the "millisecond" property (java.util.Calendar.MILLISECOND) to the specified value. |
setMinute | Function<Date,Date> | int value | Modifies a Date by setting the "minute" property (java.util.Calendar.MINUTE) to the specified value. |
setMonth | Function<Date,Date> | int value | Modifies a Date by setting the "month" property (java.util.Calendar.MONTH) to the specified value. |
setWeek | Function<Date,Date> | int value | Modifies a Date by setting the "week" property (java.util.Calendar.WEEK_OF_YEAR) to the specified value. |
setYear | Function<Date,Date> | int value | Modifies a Date by setting the "year" property (java.util.Calendar.YEAR) to the specified value. |
timeInMillisToDate | Function<Long,Date> | Converts the target Long (representing a time in milliseconds) into a Date. | |
timeInMillisToDate | Function<Long,Date> | int truncateField | Converts the target Long (representing a time in milliseconds) into a Date, truncating by the specified field (java.util.Calendar constant field). |
timestampToDate | Function<Timestamp,Date> | Converts the target java.sql.Timestamp into a Date. | |
timestampToDate | Function<Timestamp,Date> | int truncateField | Converts the target java.sql.Timestamp into a Date, truncating by the specified field (java.util.Calendar constant field). |
toCalendar | Function<Date,Calendar> | ||
toCalendar | Function<Date,Calendar> | int truncateField | |
toStr | Function<Date,String> | String pattern | Converts the target Date into a String using the specified pattern. The pattern has to be written in the java.text.SimpleDateFormat format. As no locale is specified, if pattern includes locale-dependent texts like month names (MMM) or week days (EEE), the default locale will be used for resolving these components. |
toStr | Function<Date,String> | String pattern Locale locale | Converts the target Date into a String using the specified pattern. The pattern has to be written in the java.text.SimpleDateFormat format, and the specified locale will be used for text-based pattern components (like month names or week days). |
toStr | Function<Date,String> | String pattern String locale | Converts the target Date into a String using the specified pattern. The pattern has to be written in the java.text.SimpleDateFormat format, and the specified locale will be used for text-based pattern components (like month names or week days). |
toStr | Function<Date,String> | DateStyle dateStyle TimeStyle timeStyle | Converts the target Date into a String using the specified date ( DateStyle) and time ( TimeStyle) styles. |
toStr | Function<Date,String> | DateStyle dateStyle TimeStyle timeStyle Locale locale | Converts the target Date into a String using the specified date ( DateStyle) and time ( TimeStyle) styles, and resolving text-based components like month names using the specified locale. |
toStr | Function<Date,String> | DateStyle dateStyle TimeStyle timeStyle String locale | Converts the target Calendar into a String using the specified date ( DateStyle) and time ( TimeStyle) styles, and resolving text-based components like month names using the specified locale. |
truncate | Function<Date,Date> | int calendarField | Truncates the target Date, setting the specified field as the most significant field. Based on org.apache.commons.lang.time.DateUtils.truncate(). |