Class HecTimeArray

java.lang.Object
hec.heclib.util.HecTimeArray
All Implemented Interfaces:
Serializable

public class HecTimeArray extends Object implements Serializable
See Also:
  • Field Details

    • _times

      protected HecTime[] _times
    • _numberElements

      protected int _numberElements
    • _timeZone

      protected TimeZone _timeZone
    • _viewTimeZone

      protected TimeZone _viewTimeZone
    • _showTimeAsBeginningOfDay

      protected boolean _showTimeAsBeginningOfDay
    • _globalViewTimeZone

      protected static TimeZone _globalViewTimeZone
  • Constructor Details

    • HecTimeArray

      public HecTimeArray()
    • HecTimeArray

      public HecTimeArray(int numberElements)
    • HecTimeArray

      public HecTimeArray(int[] times)
    • HecTimeArray

      public HecTimeArray(int[] times, TimeZone timezone)
    • HecTimeArray

      public HecTimeArray(HecTimeArray copyFrom)
  • Method Details

    • setGlobalViewTimeZone

      public static void setGlobalViewTimeZone(TimeZone globalViewTimeZone)
    • getGlobalViewTimeZone

      public static TimeZone 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

      public HecTime getTzUnconverted(int elementNumber)
    • elementAt

      @Deprecated public HecTime elementAt(int elementNumber)
      Deprecated.
      use getTimeInDataTimeZone(int) instead as it is more appropriately name
      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
    • getTimeInDataTimeZone

      public HecTime getTimeInDataTimeZone(int elementNumber)
      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

      public int set(int[] times, TimeZone timezone)
    • convertTimezone

      public boolean convertTimezone(TimeZone toTimeZone, boolean observeDST)
    • getTzConverted

      @Deprecated public HecTime getTzConverted(int elementNumber)
      Deprecated.
      use getTimeInViewTimeZone(int) instead as it is more appropriately named
      Returns 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 public HecTime element(int elementNumber)
      Deprecated.
      use getTimeInViewTimeZone(int) instead as it is more appropriately named
      Returns 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

      public HecTime getTimeInViewTimeZone(int elementNumber)
      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

      public void setTzUnconverted(int elementNumber, HecTime value)
    • setTzUnconverted

      public void setTzUnconverted(int elementNumber, String dateAndTime)
    • setTzConverted

      public int setTzConverted(int elementNumber, HecTime value)
      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

      public int setTzConverted(int elementNumber, String dateAndTime)
    • set

      public int set(int elementNumber, HecTime value)
    • set

      public int set(int elementNumber, String dateAndTime)
    • setElementAt

      public void setElementAt(HecTime time, int index)
    • setElementAt

      public void setElementAt(String dateAndTime, int index)
    • set

      public int set(HecTimeArray array)
    • 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

      public HecTime[] 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 - int
      numberToAdd - int
      interval - 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

      public boolean isDefined(intContainer elementNumber)
    • index

      public int index(HecTime time)
      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

      public int index(HecTime time, boolean ascending, int timeInterval)
      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

      public TimeZone getTimeZone()
      Returns a SimpleTimeZone object for the time zone set If no time zone, returns null
    • hasTimeZone

      public boolean hasTimeZone()
    • setTimeZone

      public void setTimeZone(TimeZone timeZone)
    • removeTimeZone

      public void removeTimeZone()
    • getViewTimeZone

      public TimeZone getViewTimeZone()
    • hasViewTimeZone

      public boolean hasViewTimeZone()
    • setViewTimeZone

      public void setViewTimeZone(TimeZone timeZone)
    • removeViewTimeZone

      public void removeViewTimeZone()
    • lastDefined

      public int lastDefined()
    • maximum

      public HecTime maximum(intContainer elementNumber)
    • minimum

      public HecTime minimum(intContainer elementNumber)
    • numberDefinedElements

      public int numberDefinedElements()
    • numberUndefinedElements

      public int numberUndefinedElements()
    • getZoneDisplayString

      public 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.
    • toString

      public String toString()
      Overrides:
      toString in class Object