org.op4j.functions
Class FnCalendar

Object
  extended by org.op4j.functions.FnCalendar

public final class FnCalendar
extends Object

Since:
1.0
Author:
Daniel Fernández

Method Summary
static Function<Calendar,Calendar> add(int calendarField, int amount)
           Modifies a Calendar by adding a positive or negative amount to one of its fields.
static Function<Calendar,Calendar> addDays(int amount)
           Modifies a Calendar by adding a positive or negative amount to one the "day" property (java.util.Calendar.DATE).
static Function<Calendar,Calendar> addHours(int amount)
           Modifies a Calendar by adding a positive or negative amount to one the "hour" property (java.util.Calendar.HOUR).
static Function<Calendar,Calendar> addMilliseconds(int amount)
           Modifies a Calendar by adding a positive or negative amount to one the "millisecond" property (java.util.Calendar.MILLISECOND).
static Function<Calendar,Calendar> addMinutes(int amount)
           Modifies a Calendar by adding a positive or negative amount to one the "minute" property (java.util.Calendar.MINUTE).
static Function<Calendar,Calendar> addMonths(int amount)
           Modifies a Calendar by adding a positive or negative amount to one the "month" property (java.util.Calendar.MONTH).
static Function<Calendar,Calendar> addWeeks(int amount)
           Modifies a Calendar by adding a positive or negative amount to one the "week" property (java.util.Calendar.WEEK_OF_YEAR).
static Function<Calendar,Calendar> addYears(int amount)
           Modifies a Calendar by adding a positive or negative amount to one the "year" property (java.util.Calendar.YEAR).
static Function<Calendar,Boolean> after(Calendar calendar)
           Determines whether the target Calendar represents a moment in time after the Calendar specified as a parameter.
static Function<Calendar,Boolean> before(Calendar calendar)
           Determines whether the target Calendar represents a moment in time before the Calendar specified as a parameter.
static Function<Object,Boolean> eq(Calendar object)
           Determines whether the target object and the specified object are equal by calling the equals method on the target object.
static Function<Integer[],Calendar> fieldIntegerArrayToCalendar()
           Converts an Integer[] containing the components of a date to a java.util.Calendar object.
static Function<List<Integer>,Calendar> fieldIntegerListToCalendar()
           Converts a List<Integer> containing the components of a date to a java.util.Calendar object.
static Function<String[],Calendar> fieldStringArrayToCalendar()
           Converts a String[] containing the components of a date to a java.util.Calendar object.
static Function<List<String>,Calendar> fieldStringListToCalendar()
           Converts a List<String> containing the components of a date to a java.util.Calendar object.
protected static Calendar fromInts(Integer year, Integer month, Integer day, Integer hour, Integer minute, Integer second, Integer milli)
           
static Function<Object,Boolean> isNotNull()
           Determines whether the target object is null or not.
static Function<Object,Boolean> isNull()
           Determines whether the target object is null or not.
static Function<Object,Boolean> notEq(Calendar object)
           Determines whether the target object and the specified object are NOT equal by calling the equals method on the target object.
static Function<Calendar,Calendar> round(int calendarField)
           Rounds the target Calendar, setting the specified field as the most significant field.
static Function<Calendar,Calendar> set(int calendarField, int value)
           Modifies a Calendar by setting one of its to the specified value.
static Function<Calendar,Calendar> setDay(int value)
           Modifies a Calendar by setting the "day" property (java.util.Calendar.DATE) to the specified value.
static Function<Calendar,Calendar> setHour(int value)
           Modifies a Calendar by setting the "hour" property (java.util.Calendar.HOUR) to the specified value.
static Function<Calendar,Calendar> setMillisecond(int value)
           Modifies a Calendar by setting the "millisecond" property (java.util.Calendar.MILLISECOND) to the specified value.
static Function<Calendar,Calendar> setMinute(int value)
           Modifies a Calendar by setting the "minute" property (java.util.Calendar.MINUTE) to the specified value.
static Function<Calendar,Calendar> setMonth(int value)
           Modifies a Calendar by setting the "month" property (java.util.Calendar.MONTH) to the specified value.
static Function<Calendar,Calendar> setWeek(int value)
           Modifies a Calendar by setting the "week" property (java.util.Calendar.WEEK_OF_YEAR) to the specified value.
static Function<Calendar,Calendar> setYear(int value)
           Modifies a Calendar by setting the "year" property (java.util.Calendar.YEAR) to the specified value.
static Function<Long,Calendar> timeInMillisToCalendar()
           Converts the target Long (representing a time in milliseconds) into a Calendar.
static Function<Long,Calendar> timeInMillisToCalendar(int truncateField)
           Converts the target Long (representing a time in milliseconds) into a Calendar, truncating by the specified field (java.util.Calendar constant field).
static Function<Timestamp,Calendar> timestampToCalendar()
           Converts the target java.sql.Timestamp into a Calendar.
static Function<Timestamp,Calendar> timestampToCalendar(int truncateField)
           Converts the target java.sql.Timestamp into a Calendar, truncating by the specified field (java.util.Calendar constant field).
static Function<Calendar,String> toStr(DateStyle dateStyle, TimeStyle timeStyle)
           Converts the target Calendar into a String using the specified date (DateStyle) and time (TimeStyle) styles.
static Function<Calendar,String> toStr(DateStyle dateStyle, TimeStyle timeStyle, Locale 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.
static Function<Calendar,String> toStr(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.
static Function<Calendar,String> toStr(String pattern)
           Converts the target Calendar into a String using the specified pattern.
static Function<Calendar,String> toStr(String pattern, Locale locale)
           Converts the target Calendar into a String using the specified pattern.
static Function<Calendar,String> toStr(String pattern, String locale)
           Converts the target Calendar into a String using the specified pattern.
static Function<Calendar,Calendar> truncate(int calendarField)
           Truncates the target Calendar, setting the specified field as the most significant field.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

public static final Function<Calendar,Calendar> add(int calendarField,
                                                    int amount)

Modifies a Calendar by adding a positive or negative amount to one of its fields.

Fields are specified by means of java.util.Calendar constants, like FnCalendar.add(Calendar.DAY_OF_MONTH, 1).

Parameters:
calendarField - the field that will be modified (java.util.Calendar constant).
amount - the positive or negative amount to be added
Returns:
the modified Calendar

addDays

public static final Function<Calendar,Calendar> addDays(int amount)

Modifies a Calendar by adding a positive or negative amount to one the "day" property (java.util.Calendar.DATE).

Parameters:
amount - the positive or negative amount to be added
Returns:
the modified Calendar

addHours

public static final Function<Calendar,Calendar> addHours(int amount)

Modifies a Calendar by adding a positive or negative amount to one the "hour" property (java.util.Calendar.HOUR).

Parameters:
amount - the positive or negative amount to be added
Returns:
the modified Calendar

addMilliseconds

public static final Function<Calendar,Calendar> addMilliseconds(int amount)

Modifies a Calendar by adding a positive or negative amount to one the "millisecond" property (java.util.Calendar.MILLISECOND).

Parameters:
amount - the positive or negative amount to be added
Returns:
the modified Calendar

addMinutes

public static final Function<Calendar,Calendar> addMinutes(int amount)

Modifies a Calendar by adding a positive or negative amount to one the "minute" property (java.util.Calendar.MINUTE).

Parameters:
amount - the positive or negative amount to be added
Returns:
the modified Calendar

addMonths

public static final Function<Calendar,Calendar> addMonths(int amount)

Modifies a Calendar by adding a positive or negative amount to one the "month" property (java.util.Calendar.MONTH).

Parameters:
amount - the positive or negative amount to be added
Returns:
the modified Calendar

addWeeks

public static final Function<Calendar,Calendar> addWeeks(int amount)

Modifies a Calendar by adding a positive or negative amount to one the "week" property (java.util.Calendar.WEEK_OF_YEAR).

Parameters:
amount - the positive or negative amount to be added
Returns:
the modified Calendar

addYears

public static final Function<Calendar,Calendar> addYears(int amount)

Modifies a Calendar by adding a positive or negative amount to one the "year" property (java.util.Calendar.YEAR).

Parameters:
amount - the positive or negative amount to be added
Returns:
the modified Calendar

set

public static final Function<Calendar,Calendar> set(int calendarField,
                                                    int value)

Modifies a Calendar by setting one of its to the specified value.

Fields are specified by means of java.util.Calendar constants, like FnCalendar.set(Calendar.DAY_OF_MONTH, 12).

Parameters:
calendarField - the field that will be modified (java.util.Calendar constant).
value - the new value
Returns:
the modified Calendar

setDay

public static final Function<Calendar,Calendar> setDay(int value)

Modifies a Calendar by setting the "day" property (java.util.Calendar.DATE) to the specified value.

Parameters:
value - the new value for the property
Returns:
the modified Calendar

setHour

public static final Function<Calendar,Calendar> setHour(int value)

Modifies a Calendar by setting the "hour" property (java.util.Calendar.HOUR) to the specified value.

Parameters:
value - the new value for the property
Returns:
the modified Calendar

setMillisecond

public static final Function<Calendar,Calendar> setMillisecond(int value)

Modifies a Calendar by setting the "millisecond" property (java.util.Calendar.MILLISECOND) to the specified value.

Parameters:
value - the new value for the property
Returns:
the modified Calendar

setMinute

public static final Function<Calendar,Calendar> setMinute(int value)

Modifies a Calendar by setting the "minute" property (java.util.Calendar.MINUTE) to the specified value.

Parameters:
value - the new value for the property
Returns:
the modified Calendar

setMonth

public static final Function<Calendar,Calendar> setMonth(int value)

Modifies a Calendar by setting the "month" property (java.util.Calendar.MONTH) to the specified value.

Parameters:
value - the new value for the property
Returns:
the modified Calendar

setWeek

public static final Function<Calendar,Calendar> setWeek(int value)

Modifies a Calendar by setting the "week" property (java.util.Calendar.WEEK_OF_YEAR) to the specified value.

Parameters:
value - the new value for the property
Returns:
the modified Calendar

setYear

public static final Function<Calendar,Calendar> setYear(int value)

Modifies a Calendar by setting the "year" property (java.util.Calendar.YEAR) to the specified value.

Parameters:
value - the new value for the property
Returns:
the modified Calendar

round

public static final Function<Calendar,Calendar> round(int calendarField)

Rounds the target Calendar, setting the specified field as the most significant field.

Based on org.apache.commons.lang.time.DateUtils.round().

Parameters:
calendarField - the field on which the calendar will be rounded (java.util.Calendar field).
Returns:
the resulting Calendar

truncate

public static final Function<Calendar,Calendar> truncate(int calendarField)

Truncates the target Calendar, setting the specified field as the most significant field.

Based on org.apache.commons.lang.time.DateUtils.truncate().

Parameters:
calendarField - the field on which the calendar will be truncated (java.util.Calendar field).
Returns:
the resulting Calendar

before

public static final Function<Calendar,Boolean> before(Calendar calendar)

Determines whether the target Calendar represents a moment in time before the Calendar specified as a parameter.

Parameters:
calendar - the calendar to compare to
Returns:
true if target is before, false otherwise

after

public static final Function<Calendar,Boolean> after(Calendar calendar)

Determines whether the target Calendar represents a moment in time after the Calendar specified as a parameter.

Parameters:
calendar - the calendar to compare to
Returns:
true if target is after, false otherwise

toStr

public static final Function<Calendar,String> toStr(String pattern)

Converts the target Calendar 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.

Parameters:
pattern - the pattern to be used, as specified by java.text.SimpleDateFormat.
Returns:
the String representation of the target Calendar.

toStr

public static final Function<Calendar,String> toStr(String pattern,
                                                    Locale locale)

Converts the target Calendar 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).

Parameters:
pattern - the pattern to be used, as specified by java.text.SimpleDateFormat.
locale - the locale to be used for text-based pattern components
Returns:
the String representation of the target Calendar.

toStr

public static final Function<Calendar,String> toStr(String pattern,
                                                    String locale)

Converts the target Calendar 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).

Parameters:
pattern - the pattern to be used, as specified by java.text.SimpleDateFormat.
locale - the locale to be used for text-based pattern components
Returns:
the String representation of the target Calendar.

toStr

public static final Function<Calendar,String> toStr(DateStyle dateStyle,
                                                    TimeStyle timeStyle)

Converts the target Calendar into a String using the specified date (DateStyle) and time (TimeStyle) styles.

Parameters:
dateStyle - the date style to be used
timeStyle - the time style to be used
Returns:
the String representation of the Calendar.

toStr

public static final Function<Calendar,String> toStr(DateStyle dateStyle,
                                                    TimeStyle timeStyle,
                                                    Locale 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.

Parameters:
dateStyle - the date style to be used
timeStyle - the time style to be used
locale - the locale to be used
Returns:
the String representation of the Calendar.

toStr

public static final Function<Calendar,String> toStr(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.

Parameters:
dateStyle - the date style to be used
timeStyle - the time style to be used
locale - the locale to be used
Returns:
the String representation of the Calendar.

timestampToCalendar

public static final Function<Timestamp,Calendar> timestampToCalendar()

Converts the target java.sql.Timestamp into a Calendar.

Returns:
the resulting Calendar.

timestampToCalendar

public static final Function<Timestamp,Calendar> timestampToCalendar(int truncateField)

Converts the target java.sql.Timestamp into a Calendar, truncating by the specified field (java.util.Calendar constant field).

Returns:
the resulting Calendar.

timeInMillisToCalendar

public static final Function<Long,Calendar> timeInMillisToCalendar()

Converts the target Long (representing a time in milliseconds) into a Calendar.

Returns:
the resulting Calendar.

timeInMillisToCalendar

public static final Function<Long,Calendar> timeInMillisToCalendar(int truncateField)

Converts the target Long (representing a time in milliseconds) into a Calendar, truncating by the specified field (java.util.Calendar constant field).

Returns:
the resulting Calendar.

fieldIntegerListToCalendar

public static final Function<List<Integer>,Calendar> fieldIntegerListToCalendar()

Converts a List<Integer> containing the components of a date to a java.util.Calendar object.

The target list can contain the following combinations of elements, in the specified order:

Returns:
the resulting Calendar

fieldIntegerArrayToCalendar

public static final Function<Integer[],Calendar> fieldIntegerArrayToCalendar()

Converts an Integer[] containing the components of a date to a java.util.Calendar object.

The target array can contain the following combinations of elements, in the specified order:

Returns:
the resulting Calendar

fieldStringListToCalendar

public static final Function<List<String>,Calendar> fieldStringListToCalendar()

Converts a List<String> containing the components of a date to a java.util.Calendar object.

The target list can contain the following combinations of elements, all of them in numeric format, in the specified order:

Returns:
the resulting Calendar

fieldStringArrayToCalendar

public static final Function<String[],Calendar> fieldStringArrayToCalendar()

Converts a String[] containing the components of a date to a java.util.Calendar object.

The target array can contain the following combinations of elements, all of them in numeric format, in the specified order:

Returns:
the resulting Calendar

eq

public static final Function<Object,Boolean> eq(Calendar object)

Determines whether the target object and the specified object are equal by calling the equals method on the target object.

Parameters:
object - the object to compare to the target
Returns:
true if both objects are equal, false if not.

notEq

public static final Function<Object,Boolean> notEq(Calendar object)

Determines whether the target object and the specified object are NOT equal by calling the equals method on the target object.

Parameters:
object - the object to compare to the target
Returns:
false if both objects are equal, true if not.

isNull

public static final Function<Object,Boolean> isNull()

Determines whether the target object is null or not.

Returns:
true if the target object is null, false if not.

isNotNull

public static final Function<Object,Boolean> isNotNull()

Determines whether the target object is null or not.

Returns:
false if the target object is null, true if not.

fromInts

protected static Calendar fromInts(Integer year,
                                   Integer month,
                                   Integer day,
                                   Integer hour,
                                   Integer minute,
                                   Integer second,
                                   Integer milli)
                            throws Exception
Throws:
Exception


Copyright © 2012 The OP4J team. All Rights Reserved.