de.jaret.util.date.iterator
Interface DateIterator

All Known Implementing Classes:
AbstractDateIterator, DayIterator, HourIterator, MillisecondIterator, MinuteIterator, MonthIterator, SecondIterator, WeekIterator, YearIterator

public interface DateIterator

Interface describing an iterator for dates.

Version:
$Id: DateIterator.java 883 2009-10-07 21:03:00Z kliem $
Author:
kliem

Nested Class Summary
static class DateIterator.Format
          Enumeration for the different format types.
 
Method Summary
 long getApproxStepMilliSeconds()
          Return the approximate step between dates in milli seconds.
 String getLabel(JaretDate date, DateIterator.Format format)
          Retrieve a label for a given date.
 JaretDate getNextDate()
          Retrieve the next date from the iterator.
 boolean hasNextDate()
          Check whether the iterator will supply a next date.
 JaretDate previewNextDate()
          Retrieve the next date without modifying the iterator.
 void reInitialize(JaretDate startDate, JaretDate endDate)
          (re)initialize the iterator with a start and an end date.
 void setCorrectDST(boolean correctDST)
          If the correct DST flag is set to true, the iterator will add/remove an hour if the DST switch time has been passed.
 void setFormatter(IIteratorFormatter formatter)
          Set a formatter to be used with this iterator overriding the default formatting.
 

Method Detail

reInitialize

void reInitialize(JaretDate startDate,
                  JaretDate endDate)
(re)initialize the iterator with a start and an end date.

Parameters:
startDate - first date that will be returned in subsequent calls
endDate - last date that will be returned

getNextDate

JaretDate getNextDate()
Retrieve the next date from the iterator.

Returns:
next date

hasNextDate

boolean hasNextDate()
Check whether the iterator will supply a next date.

Returns:
true if the next call to getNextDate() will return a valid date

previewNextDate

JaretDate previewNextDate()
Retrieve the next date without modifying the iterator.

Returns:
the next valid date or null if no subsequent date is available

getLabel

String getLabel(JaretDate date,
                DateIterator.Format format)
Retrieve a label for a given date.

Parameters:
date - the date to format
format - short, medium or long
Returns:
label

setFormatter

void setFormatter(IIteratorFormatter formatter)
Set a formatter to be used with this iterator overriding the default formatting.

Parameters:
formatter - the formatter to use.

getApproxStepMilliSeconds

long getApproxStepMilliSeconds()
Return the approximate step between dates in milli seconds.

Returns:
approximate step between iterated dates in milli seconds

setCorrectDST

void setCorrectDST(boolean correctDST)
If the correct DST flag is set to true, the iterator will add/remove an hour if the DST switch time has been passed. This is false by default and you should only use it if you are knowing what you are doing. This uses the Default TimeZone for determining DST switches.



Copyright © 2013. All Rights Reserved.