Package hec.heclib.util
Class HecTimeArray
java.lang.Object
hec.heclib.util.HecTimeArray
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHecTimeArray
(int numberElements) HecTimeArray
(int[] times) HecTimeArray
(int[] times, TimeZone timezone) HecTimeArray
(HecTimeArray copyFrom) -
Method Summary
Modifier and TypeMethodDescriptionboolean
convertTimezone
(TimeZone toTimeZone, boolean observeDST) element
(int elementNumber) Deprecated.elementAt
(int elementNumber) Deprecated.usegetTimeInDataTimeZone(int)
instead as it is more appropriately namestatic TimeZone
int[]
getTimeInDataTimeZone
(int elementNumber) Returns the HecTime at the given index in the DATA TimeZonegetTimeInViewTimeZone
(int elementNumber) Returns the HecTime at the given index in the VIEW TimeZoneReturns a SimpleTimeZone object for the time zone set If no time zone, returns nullgetTzConverted
(int elementNumber) Deprecated.usegetTimeInViewTimeZone(int)
instead as it is more appropriately namedgetTzUnconverted
(int elementNumber) static String
getZoneDisplayString
(TimeZone timeZone) Reurns a time zone display string for the user, clarified for US time zones This string should go in tables, plots, etc.boolean
boolean
int
Search the time array to determine if the provided time is in the time array (the time, not the address of the time).int
Search the time array to determine if the provided time is in the time array (the time, not the address of the time).boolean
boolean
isDefined
(intContainer elementNumber) int
maximum
(intContainer elementNumber) minimum
(intContainer elementNumber) int
int
int
void
void
int
resize
(int numberElements) Resize the array.int
resize
(int numberElements, int beginningElement) Resize the array.int
resize
(int numberElements, int beginningElementOld, int beginningElementNew) Resize the array, while moving elements (a more complex resize) numberElements is the new size beginningElementOld is the position in the old array to start copying from beginningElementNew is the position in the new array to start copying to This function can be used to increase the size of the array (most common), or remove data from the beginning and end of the array.void
resizeWithInterval
(int startElement, int numberToAdd, int interval) For arrays with regular interval times, resize and modify times to be correct.int
set
(int[] timeArray) int
set
(int[] timeArray, int julianBaseDate) int
set
(int[] timeArray, int timeGranularitySeconds, int julianBaseDate) int
int
int
int
set
(HecTimeArray array) void
setElementAt
(HecTime time, int index) void
setElementAt
(String dateAndTime, int index) static void
setGlobalViewTimeZone
(TimeZone globalViewTimeZone) int
setSize
(int numberElements) void
setTimeZone
(TimeZone timeZone) int
setTzConverted
(int elementNumber, HecTime value) Sets the HecTime object at the element number given.int
setTzConverted
(int elementNumber, String dateAndTime) void
setTzUnconverted
(int elementNumber, HecTime value) void
setTzUnconverted
(int elementNumber, String dateAndTime) void
void
setViewTimeZone
(TimeZone timeZone) void
showTimeAsBeginningOfDay
(boolean showTimeAsBeginningOfDay) Show midnight at the beginning of the next day, instead of the end of the previous day.HecTime[]
toString()
-
Field Details
-
_times
-
_numberElements
protected int _numberElements -
_timeZone
-
_viewTimeZone
-
_showTimeAsBeginningOfDay
protected boolean _showTimeAsBeginningOfDay -
_globalViewTimeZone
-
-
Constructor Details
-
HecTimeArray
public HecTimeArray() -
HecTimeArray
public HecTimeArray(int numberElements) -
HecTimeArray
public HecTimeArray(int[] times) -
HecTimeArray
-
HecTimeArray
-
-
Method Details
-
setGlobalViewTimeZone
-
getGlobalViewTimeZone
-
showTimeAsBeginningOfDay
public void showTimeAsBeginningOfDay(boolean showTimeAsBeginningOfDay) Show midnight at the beginning of the next day, instead of the end of the previous day. (For example, 06Jan2002 00:00, instead of 05Jan2002 24:00.)- Parameters:
showTimeAsBeginningOfDay
- true to show midnight as 00:00 hrs, false to show midnight as 24:00 hrs (default).
-
getTzUnconverted
-
elementAt
Deprecated.usegetTimeInDataTimeZone(int)
instead as it is more appropriately nameReturns the HecTime at the given index in the DATA TimeZone- Parameters:
elementNumber
- index of the requested time- Returns:
- HecTime for the index in the DATA TimeZone
-
getTimeInDataTimeZone
Returns the HecTime at the given index in the DATA TimeZone- Parameters:
elementNumber
- index of the requested time- Returns:
- HecTime for the index in the DATA TimeZone
-
set
-
convertTimezone
-
getTzConverted
Deprecated.usegetTimeInViewTimeZone(int)
instead as it is more appropriately namedReturns a COPY of the HecTime object at the element number given, usually used for display. The HecTime object will be adjusted for time zones and daylight savings time differences according to the data time zone (setTimeZone) and the display time zone (static globalViewTimeZone) For direct access to the object (such as when setting) use function elementAt(int elementNumber)- Parameters:
elementNumber
- index of the requested time- Returns:
- HecTime for the index in the VIEW TimeZone
-
element
Deprecated.usegetTimeInViewTimeZone(int)
instead as it is more appropriately namedReturns a COPY of the HecTime object at the element number given, usually used for display. The HecTime object will be adjusted for time zones and daylight savings time differences according to the data time zone (setTimeZone) and the display time zone (static globalViewTimeZone) For direct access to the object (such as when setting) use function elementAt(int elementNumber)- Parameters:
elementNumber
- index of the requested time- Returns:
- HecTime for the index in the VIEW TimeZone
-
getTimeInViewTimeZone
Returns the HecTime at the given index in the VIEW TimeZone- Parameters:
elementNumber
- index of the requested time- Returns:
- HecTime for the index in the VIEW TimeZone
-
setTzUnconverted
-
setTzUnconverted
-
setTzConverted
Sets the HecTime object at the element number given. The HecTime object will be adjusted for time zones and daylight savings time differences according to the data time zone (setTimeZone) and the display time zone (static globalViewTimeZone) For direct access to the object (such as when setting) use function setElementAt -
setTzConverted
-
set
-
set
-
setElementAt
-
setElementAt
-
set
-
set
public int set(int[] timeArray, int timeGranularitySeconds, int julianBaseDate) -
set
public int set(int[] timeArray, int julianBaseDate) -
set
public int set(int[] timeArray) -
getIntArray
public int[] getIntArray() -
setUndefined
public void setUndefined() -
numberElements
public int numberElements() -
timeArray
-
setSize
public int setSize(int numberElements) -
resize
public int resize(int numberElements) Resize the array. numberElements is the new size Removes elements from the end, or adds elements to the end Example: For an arrary of 3, then resize(5) resize(2) 10 --> 10 10 11 11 11 12 12 __ __ -
resize
public int resize(int numberElements, int beginningElement) Resize the array. numberElements is the new size beginningElement is where to start deleting elements from, if decreasing beginningElement is where to start adding (undefined) elements to, if increasing Example: For an arrary of 3, then resize(5,1) resize(2,1) 10 --> 10 10 11 __ 12 12 __ 11 12 -
resizeWithInterval
public void resizeWithInterval(int startElement, int numberToAdd, int interval) For arrays with regular interval times, resize and modify times to be correct. Handles adding elements at the beginning of the array. To append, startElement should be the last element + 1.- Parameters:
startElement
- intnumberToAdd
- intinterval
- int
-
resize
public int resize(int numberElements, int beginningElementOld, int beginningElementNew) Resize the array, while moving elements (a more complex resize) numberElements is the new size beginningElementOld is the position in the old array to start copying from beginningElementNew is the position in the new array to start copying to This function can be used to increase the size of the array (most common), or remove data from the beginning and end of the array. Example: For an arrary of 3, then resize(5,1,2) resize(2,1,1) 10 --> __ __ 11 __ 11 12 11 12 __ Any new values are undefined. -
isDefined
public boolean isDefined() -
isDefined
-
index
Search the time array to determine if the provided time is in the time array (the time, not the address of the time). Returns the element number of that time, or -1 if not found. This is a brute force approach. If you know the times are ascending, use the other contains() function. -
index
Search the time array to determine if the provided time is in the time array (the time, not the address of the time). Returns the element number of that time, or -1 if not found. This is a quicker search if you know the times are in ascending order. If you think that the times might have a regular time interval, then provide the time interval in minutes for a quick check (if not found, it will check the regular way). If the times do not have a regular interval, enter 0 for the timeInterval. -
getTimeZone
Returns a SimpleTimeZone object for the time zone set If no time zone, returns null -
hasTimeZone
public boolean hasTimeZone() -
setTimeZone
-
removeTimeZone
public void removeTimeZone() -
getViewTimeZone
-
hasViewTimeZone
public boolean hasViewTimeZone() -
setViewTimeZone
-
removeViewTimeZone
public void removeViewTimeZone() -
lastDefined
public int lastDefined() -
maximum
-
minimum
-
numberDefinedElements
public int numberDefinedElements() -
numberUndefinedElements
public int numberUndefinedElements() -
getZoneDisplayString
Reurns a time zone display string for the user, clarified for US time zones This string should go in tables, plots, etc. -
toString
-
getTimeInViewTimeZone(int)
instead as it is more appropriately named