net.sf.jasperreports.types.date

## Class DateRangeBuilder

- java.lang.Object
- - net.sf.jasperreports.types.date.DateRangeBuilder

-     public class DateRangeBuilder
      extends java.lang.Object

  Builder which allows to build proper instance of `DateRange`

  Usage example:

  `DateRange range = new DateRangeBuilder("DAY").set(TimeZone.getTimeZone("GMT")).setValueClass(Timestamp.class).toDateRange()`
  Version:
    $Id: DateRangeBuilder.java 5880 2013-01-07 20:40:06Z teodord $
  Author:
    Sergey Prilukin

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DateRangeBuilder(java.util.Date dateValue)` Constructor which allows to create DateRange instance from passed date instance.
    `DateRangeBuilder(java.lang.String expression)` Constructor which allows to create DateRange instance from passed string expression.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DateRangeBuilder` | `set(java.lang.Class<? extends java.util.Date> valueClass)` Configuration method which sets value class, to indicate desired class of DateRange.getStart and DateRange.getEnd methods.
    `DateRangeBuilder` | `set(java.lang.Integer weekStartDay)` Configuration method which set start of a week which will be used during DateRange.getStart and DateRange.getEnd calculations.
    `DateRangeBuilder` | `set(java.util.Locale locale)` Configuration method which set start of a week which will be used during DateRange.getStart and DateRange.getEnd calculations from passed locale instance NOTE: This method and `set(Integer)` will overwrite each other so configuration which was set later will be used.
    `DateRangeBuilder` | `set(java.lang.String datePattern)` Configuration method which sets date pattern which will be used to parse expression NOTE: this method only will take effect if expression is in fact formatted date like "1970-01-01".
    `DateRangeBuilder` | `set(java.util.TimeZone timeZone)` Configuration method which sets desired time zone which will be used to calculate DateRange.getStart and DateRange.getEnd.
    `DateRange` | `toDateRange()` `Returns instance of `DateRange` based on which configuration methods was called`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DateRangeBuilder

          public DateRangeBuilder(java.util.Date dateValue)

      Constructor which allows to create DateRange instance from passed date instance.

      No additional configuration via `set` methods is necessary

      Parameters:
        `dateValue` - date instance to create DateRange instance

    - #### DateRangeBuilder

          public DateRangeBuilder(java.lang.String expression)

      Constructor which allows to create DateRange instance from passed string expression.

      It is usually necessary to pass additional configuration through `set` methods

      Parameters:
        `expression` - string expression which will be parsed in order to construct instance of DateRange

  - ### Method Detail

    - #### set

          public DateRangeBuilder set(java.lang.String datePattern)

      Configuration method which sets date pattern which will be used to parse expression

      NOTE: this method only will take effect if expression is in fact formatted date like "1970-01-01".

      Parameters:
        `datePattern` - date pattern which will be used to parse date
      Returns:
        this instance of DateRangeBuilder
      See Also:
        `SimpleDateFormat`

    - #### set

          public DateRangeBuilder set(java.lang.Class<? extends java.util.Date> valueClass)

      Configuration method which sets value class, to indicate desired class of DateRange.getStart and DateRange.getEnd methods.

      NOTE: this method will not take effect if `DateRangeBuilder(java.util.Date)` constructor was used.

      Parameters:
        `valueClass` - class instance of which will be returned by DateRange.getStart and DateRange.getEnd methods
      Returns:
        this instance of DateRangeBuilder

    - #### set

          public DateRangeBuilder set(java.util.TimeZone timeZone)

      Configuration method which sets desired time zone which will be used to calculate DateRange.getStart and DateRange.getEnd.

      NOTE: this method will not take effect if `DateRangeBuilder(java.util.Date)` constructor was used.

      Parameters:
        `timeZone` - time zone which will be used to calculate DateRange.getStart and DateRange.getStart.
      Returns:
        this instance of DateRangeBuilder

    - #### set

          public DateRangeBuilder set(java.lang.Integer weekStartDay)

      Configuration method which set start of a week which will be used during DateRange.getStart and DateRange.getEnd calculations.

      Should be one of: `Calendar.SUNDAY`, `Calendar.MONDAY`

      NOTE: this method only will take effect if expression is in fact date range expression like "WEEK".

      Parameters:
        `weekStartDay` - week start day to calculate DateRange.getStart and DateRange.getEnd for expressions like "WEEK"
      Returns:
        this instance of DateRangeBuilder

    - #### set

          public DateRangeBuilder set(java.util.Locale locale)

      Configuration method which set start of a week which will be used during DateRange.getStart and DateRange.getEnd calculations from passed locale instance

      NOTE: This method and `set(Integer)` will overwrite each other so configuration which was set later will be used.

      NOTE: this method only will take effect if expression is in fact date range expression like "WEEK".

      Parameters:
        `locale` - locale to calculate DateRange.getStart and DateRange.getEnd for expressions like "WEEK"
      Returns:
        this instance of DateRangeBuilder

    - #### toDateRange

          public DateRange toDateRange()
                                throws InvalidDateRangeExpressionException

      `Returns instance of `DateRange` based on which configuration methods was called`
      Returns:
        instance of `DateRange`
      Throws:
        `InvalidDateRangeExpressionException` - if could not instantiate `DateRange` using passed expression

© 2001-2010 Jaspersoft Corporation www.jaspersoft.com