Package hec.heclib.util
Class HecTime
java.lang.Object
hec.heclib.util.HecTime
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable
- Direct Known Subclasses:
GridTime
,HecTimeComparator
HecTime holds a date and a time value, and performs various functions with those values, such as incrementing
a date/time or returning a date/time in a formatted string in a specific style.
The date component is stored as the number of days since the base date. The default base date is 31Dec1899 at 2400.
The time component is stored as seconds past midnight for the specified day
In addition, the 'granularity' of the HecTime object may be set to specify the precision of the values returned
by the various HecTime functions (methods).
The granularity determines if the date/time is to be used and/or reported to the nearest:
second
minute
hour or
day.
For example, if you were to set the granularity to 'hour', the time would always be computed and displayed
'at the top of the hour' (with zero minutes); i.e, you would get 0800 or 0900 for the time, but not 0830.
HecTime does not support a time granularity of less than one second
The following examples demonstrate granularity by showing the results of the value() method between two
successive Date/Time values.
SECOND_GRANULARITY
'01Jan1960 01:01:01' value() = -315615539
'01Jan1960 01:01:02' value() = -315615538.
HOUR_GRANULARITY
'01Jan1960 01:01' value() = 525961
'01Jan1960 02:01' value() = 525962
MINUTE_GRANULARITY
'01Jan1960 01:01' value() = 31557661
'01Jan1960 01:02' value() = 31557662
DAY_GRANULARITY
'01Jan1960' value() 21915
'02Jan1960' value() 21916
value() returns an integer representation of the date/time. Note: This integer value overflows when the boundaries
of an integer range are crossed (-2147483648 to 2147483647) so value() may return negative values or positive values.
Most time series data is reported as end-of-period values; for example, a daily average data value cannot be
computed until the end of the day. The default reporting for HecTime is end-of-period,
meaning that midnight occurs at the end of the day, not at the beginning.
A midnight time will be returned as '2400'
note: 02Feb2020 24:00 in HecTime is equivalent to 03Feb2020 00:00
in Java or Excel.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected int
protected int
protected int
protected boolean
static final int
static final int
protected static DecimalFormat
protected static DecimalFormat
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorsConstructorDescriptionHecTime()
Default constructor: Time is undefined, resolution to nearest minute.HecTime
(int timeGranularity) HecTime constructor Time is undefinedHecTime
(int value, int timeGranularity) HecTime constructorCopy ConstructorHecTime constructorHecTime constructorHecTime constructorHecTime constructorSets date / time to a Java Calendar object.Sets date / time to a Java Date object -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int time) Adds a given amount of time to the current time.void
Add an HecTime to this object (adds the times together)static int
addCentury
(int intYear) This takes a two digit year and adds the "correct" centuryvoid
addDays
(int days) void
addHours
(int hours) void
addMinutes
(int minutes) void
addSeconds
(int seconds) void
adjustToIntervalOffset
(int intervalMinutes, int offset) Adjust the time to be at the interval offset (in minutes) provided.void
protected void
cleanTime
(int[] times) clone()
int
compareTimes
(HecTime time) Compares this time with input time.int
compareTostatic int
computeNumberIntervals
(int startTimeMins, int endTimeMins, int intervalInMins) Get the number of periods between two times given in minutes (Heclib nopers function)int
computeNumberIntervals
(HecTime otherTime, int intervalInMins) Get the number of periods between two times (Heclib nopers function)int
computeNumberIntervalsSecs
(HecTime otherTime, int intervalInSecs) static void
convertTimeZone
(HecTime hecTime, TimeZone fromTimeZone, TimeZone toTimeZone) Converts the HecTime from the fromTimeZone to the toTimeZone Respectes Daylight savings timestatic void
convertTimeZone
(HecTime hecTime, TimeZone fromTimeZone, TimeZone toTimeZone, boolean respectDST) Converts the HecTime from the fromTimeZone to the toTimeZone User decides on respecting Daylight savings timestatic HecTime
convertToTimeZone
(int minsSince1900, TimeZone fromTimeZone, TimeZone toTimeZone) Convience function for convertTimeZone * Converts the HecTime from the fromTimeZone to the toTimeZone Respectes Daylight savings timestatic HecTime
convertToTimeZone
(HecTime hecTime, TimeZone fromTimeZone, TimeZone toTimeZone) Convience function for convertTimeZone Returns a COPY of the time, with the original left unchanged Converts the HecTime from the fromTimeZone to the toTimeZone Respectes Daylight savings timestatic void
curtim
(int[] julian, int[] minutes) This method returns a julian date and the number of minutes since midnight in the current time zonestatic void
datcln
(int julianIn, int timeIn, int[] julianOut, int[] timeOut) This method cleans up the date and minutes so that timeOut is never greater than 1440 minutes.date()
Returns a String representation for the data part of HecTime in the format 2 June 1985.date
(int style) Returns a String representation for the date part of HecTimeReturns the date and time represented by this object as a string.dateAndTime
(int style) Returns a string representation of the date and time in the form of, TTTT. static int
Takes a character date, in a variety of styles, and converts it into a Julian date in days since December 31, 1899.static void
datjul
(String charDate, intContainer julian, intContainer errorCode) Takes a character date, in a variety of styles, and converts it into a Julian date in days since December 31, 1899.static int
Takes a character date, in a variety of styles, and converts it into an integer year-month-day style date.static void
datymd
(String charDate, intContainer year, intContainer month, intContainer day, intContainer errorCode) Takes a character date, in a variety of styles, and converts it into an integer year-month-day style date.int
day()
returns the day of the monthint
Returns the day of the week as an int.Returns a string containing the name of the day of the week (e.g., "Sunday", "Monday")int
Returns the julian day of the year, with Jan 1 = 1, Jan 2 = 2boolean
Determine if two HecTime object contain equal timesstatic HecTime
fromInstant
(Instant instant, ZoneId zoneId) static HecTime
fromZonedDateTime
(ZonedDateTime zonedDateTime) int
static void
Obtains a time window from a program command line input in the local time zonestatic void
Obtains a time window from a program command line input.getInstant
(ZoneId zoneId) int
getIntervalOffset
(int intervalMinutes) Compute the time offset from the provided time interval in minutes, for standard intervals used in DSS.getJavaDate
(int minutesTimezoneOffset) Returns a Java Date object for this date / timelong
Get Julian date / time in minutes.long
getMinutes
(int minutesTimezoneOffset) Get Julian date / time in minutes.boolean
Get the object setting if midnight is shown as the beginning of the next daygetTime
(boolean withColons) Get the time portion as user displayable string withColons == true, hh:mm:ss withColons == false, hhmm For example, if withColons, return "08:30:00", withColons == false, return "0830"int
Gets the time resolutionint
Gets the time resolution in units of secondsint
Deprecated.long
Get the date / time in milliseconds (same units that Java uses) in UTC.long
getTimeInMillis
(int minutesTimezoneOffset) Get the date / time in milliseconds (same units that Java uses)long
getTimeInMillis
(Calendar cal) Get the date / time in milliseconds (same units that Java uses)static int
getTimeWindow
(String userLine, HecTime startTime, HecTime endTime) A general purpose function to take a users time window input line, and compute a starting time and ending time For example "20May95 1200 13Jan97 0500" or "t-5d, t" The start time and end time are adjusted if specified (e.g., "-5D +2H") Implements Heclib getime routinegetXMLDateTime
(int minutesTimezoneOffset) Returns a String for this date / time, formatted for use in XMLboolean
greaterThan
(HecTime time) Determine if this object has a time greater than the one passed inboolean
greaterThanEqualTo
(HecTime time) Determine if this object has a time greater than or equal to the one passed inint
hour()
returns the hour of the time portion (0 - 24)Returns a string representation in the form HHMMint
hoursMinutesSeconds
(intContainer hiHours, intContainer hiMinutes, intContainer hiSeconds) Obtains the time portion in int containers as hours, minutes and secondsstatic int
idaywk
(int jul) Returns integer day of week.static int
Takes a character string containing a twenty-four hour military style clock time (e.g., '1630'), and converts it into minutes past midnight.static int
Version of ihm2m that has the same behavior as a JNI call to Hec_ihm2m.void
increment
(int numberPeriods, int minutesInPeriod) Add a number of time periods to this date / timevoid
incrementSecs
(int numberPeriods, int secondsInPeriod) static void
inctim
(int interval, int numPeriods, int startJulian, int startTime, int[] endJulian, int[] endTime) increments a Julian date and time a specified number of periods, based on a given time interval.static int
inctim
(int interval, int unitFlag, int numPeriods, int startJulian, int startTime, intContainer endJulian, intContainer endTime) increments a Julian date and time a specified number of periods, based on a given time interval.static boolean
Deprecated.boolean
boolean
Returns if the date / time is definedstatic boolean
isLeap
(int year) Checks if a given year is a leap yearint
isoDate()
Generates and retuns an ISO style date as an int: YYMMDDint
isoTime()
Generate and return an ISO style time as an int: HHMMSSboolean
static int
iymdjl
(int intYear, int intMonth, int intDay) Returns the Julian date in days since 31 December 1899 for an integer date passed in the form of year, month, daystatic int
jliymd
(int jul, int[] ymd) static int
jliymd
(int jul, intContainer year, intContainer month, intContainer day) static String
juldat
(int julian, int style) Takes a Julian date and a date style code and returns a string of the date in the style requested.int
julian()
Returns the HEC julian datestatic int
julianToYearMonthDay
(int julian, intContainer year, intContainer month, intContainer day) boolean
Determine if this object has a time less than the one passed inboolean
lessThanEqualTo
(HecTime time) Determine if this object has a time less than or equal to the one passed instatic int
m2ihm
(int minutes, stringContainer hourMinutes) Generates a four-character hour/minute string from minutes since midnight.static void
static int
maxDay
(int year, int month) Returns the last day of a monthint
minute()
Returns the number of minutes past the hour of the timeint
Returns the number of minutes past midnight for the time portionint
month()
Returns the month of the date, with Jan = 1, Feb = 2static int
nopers
(int interval, int startJulian, int startTime, int endJulian, int endTime) Given two dates and times, and a time interval, the method NOPERS will determine the number of periods between them.static int
nopers
(int interval, int unitFlag, int startJulian, int startTime, int endJulian, int endTime) Given two dates and times, and a time interval, the method NOPERS will determine the number of periods between them.static int
normalizeDateStyle
(int style) Returns a valid date style based on an input style.boolean
notEqualTo
(HecTime time) Determine if two HecTime object contain equal timesint
second()
Returns the number of seconds past the last minute of the timeint
Returns the number of seconds since midnight for the time portion if time is not defined, will return UNDEFINED_VALUEvoid
set
(int value) Set the date / time to this value (in increments) For default granularity, this is in minutes.void
set
(int value, int julianBaseDate) void
set
(int value, int valueGranularitySeconds, int julianBaseDate) void
Copies a HecTime objectint
Sets a string containing both the date and timeint
Set the date and timevoid
Sets date / time to a Java Calendar object.void
Sets date / time to a Java Date objectstatic void
setAlwaysShowTimeAsBeginningOfDay
(boolean alwaysShowBeginningOfDay) Deprecated.void
Sets the object to the current system time.int
Sets the date portion to the date string passed invoid
setDefaultDateStyle
(int defaultDateStyle) Sets the default String representation for the date part of HecTimevoid
setJulian
(int julian) Sets the date to the Hec julian datevoid
setJulian
(int julian, int minutesSinceMidnight) Sets the date to the Hec julian date and minutes past midnightvoid
setJulian
(int julian, int minutesSinceMidnight, int secondsSinceMinute) Sets the date to the Hec julian date and minutes and seconds past midnight.void
setMinutes
(double minutes) Set the time in minutes since 31 Dec 1899void
setMinutes
(long minutes) Set the time in minutes since 31 Dec 1899void
setMinutes
(long minutes, int minutesTimezoneOffset) Set the time in minutes since 31 Dec 1899void
setSeconds
(long value) int
Sets the time portion to the time string passed in (e.g., "1300")void
setTimeGranularity
(int baseGranularity) Sets or changes the time resolution (granularity).void
setTimeGranularityInSeconds
(int timeGranularityInSeconds) Sets the time resolution (granularity) using units of seconds.void
setTimeIncrement
(int baseGranularity) Deprecated.void
setTimeInMillis
(long milliseconds) Set the time in milliseconds (same units used by Java)void
setTimeInMillis
(long milliseconds, int minutesTimezoneOffset) set the time in milliseconds (same units used by Java), along with a time zone offsetvoid
Set the date / time to undefinedint
Sets a string containing both the date and time in XML dateTime (ISO 8601) format.void
setYearMonthDay
(int year, int month, int day) Sets the date to the year, month, day value and minutes past midnight Time is not changed (if not defined, left undefined)void
setYearMonthDay
(int year, int month, int day, int minutesSinceMidnight) Sets the date to the year, month, day value and minutes past midnightvoid
showTimeAsBeginningOfDay
(boolean showBeginning) Show midnight at the beginning of the next day, instead of the end of the previous day.void
subtract
(int time) Subtracts a given amount of time to the current time.void
Subtract an HecTime from this date / timevoid
subtractDays
(int days) void
subtractHours
(int hours) void
subtractMinutes
(int minutes) void
subtractSeconds
(int seconds) static void
systim
(int[] julian, int[] seconds) This method returns a julian date and the number of seconds since midnight in the current time zonestatic void
This method returns the current julian date and time (in minutes or seconds)time()
Get the time portion as user displayable string (For example, "08:30:00")int
int
Deprecated.use timeGranularity() insteadtoString()
Returns the date and time in a user format (e.g., "10 June 2002, 13:03:42")toString
(int dateStyle) Returns the date and time in the format specifiedint
value()
Computes and returns an int representation of the date/time Opposite of set(int).int
year()
Returns the 4 digit year of the date (e.g., 2002)int
yearMonthDay
(intContainer hiYear, intContainer hiMonth, intContainer hiDay) Returns the date portion in int containers as years, months, daysstatic int
yearMonthDayToJulian
(int year, int month, int day) static String
ymddat
(int[] ymd, int style, int[] err) Takes a date and a date style code and returns a string of the date in the style requested.static void
zofset
(int[] julian, int[] iTime, int interval, int iFlag, int[] iOffset) Determine the time offset for regular interval time series data
-
Field Details
-
SECOND_INCREMENT
public static final int SECOND_INCREMENT- See Also:
-
MINUTE_INCREMENT
public static final int MINUTE_INCREMENT- See Also:
-
HOUR_INCREMENT
public static final int HOUR_INCREMENT- See Also:
-
DAY_INCREMENT
public static final int DAY_INCREMENT- See Also:
-
SECOND_GRANULARITY
public static final int SECOND_GRANULARITY- See Also:
-
MINUTE_GRANULARITY
public static final int MINUTE_GRANULARITY- See Also:
-
HOUR_GRANULARITY
public static final int HOUR_GRANULARITY- See Also:
-
DAY_GRANULARITY
public static final int DAY_GRANULARITY- See Also:
-
UNDEFINED_VALUE
public static final int UNDEFINED_VALUE- See Also:
-
_julian
protected int _julian -
_secondsSinceMidnight
protected int _secondsSinceMidnight -
_baseGranularity
protected int _baseGranularity -
_showBeginning
protected boolean _showBeginning -
_defaultDateStyle
protected int _defaultDateStyle -
dfmt2
-
dfmt4
-
-
Constructor Details
-
HecTime
public HecTime()Default constructor: Time is undefined, resolution to nearest minute. -
HecTime
public HecTime(int timeGranularity) HecTime constructor Time is undefined- Parameters:
timeGranularity
- defines base granularity:Second: HecTime.SECOND_GRANULARITY Minute: HecTime.MINUTE_GRANULARITY Hour: HecTime.HOUR_GRANULARITY Day: HecTime.DAY_GRANULARITY
-
HecTime
public HecTime(int value, int timeGranularity) HecTime constructor- Parameters:
value
- (increments) since start of base - default minutes. For minutes, hours, or days, this is increments since 0000 on Dec 31 1899 (Jan 01, 1900 is defined as day 1). For seconds, this is seconds since 19Jan1970 at 0000 (same as Unix base time).timeGranularity
- defines base granularity:Second: HecTime.SECOND_GRANULARITY Minute: HecTime.MINUTE_GRANULARITY Hour: HecTime.HOUR_GRANULARITY Day: HecTime.DAY_GRANULARITY
-
HecTime
HecTime constructor- Parameters:
date
- date string in a variety of formatstime
- time string in hours:minutes:seconds (colons not necessary). If resolution is not to the nearest second, seconds are ignored (and not needed).
-
HecTime
HecTime constructor- Parameters:
date
- date string in a variety of formats.time
- time string in hours:minutes:seconds (colons not necessary). If resolution is not to nearest second, seconds are ignored (and not needed).timeGranularity
- sets base Granularity:Second: HecTime.SECOND_GRANULARITY Minute: HecTime.MINUTE_GRANULARITY Hour: HecTime.HOUR_GRANULARITY Day: HecTime.DAY_GRANULARITY
-
HecTime
HecTime constructor- Parameters:
date
- date string in a variety of formats.
-
HecTime
HecTime constructor- Parameters:
date
- date string in a variety of formats.timeGranularity
- sets base Granularity:Second: HecTime.SECOND_GRANULARITY Minute: HecTime.MINUTE_GRANULARITY Hour: HecTime.HOUR_GRANULARITY Day: HecTime.DAY_GRANULARITY
-
HecTime
Sets date / time to a Java Date object- Parameters:
javaDate
- Java Date objectminutesTimezoneOffset
- time zone offset in minutes for this date
-
HecTime
Sets date / time to a Java Calendar object. Takes care of time offset and daylight savings time.- Parameters:
cal
- Java Calendar object
-
HecTime
Copy Constructor- Parameters:
hecTime
-
-
-
Method Details
-
fromZonedDateTime
-
fromInstant
-
setAlwaysShowTimeAsBeginningOfDay
Deprecated. -
isAlwaysShowTimeAsBeginningOfDay
Deprecated.- Returns:
- boolean
-
setTimeGranularityInSeconds
public void setTimeGranularityInSeconds(int timeGranularityInSeconds) Sets the time resolution (granularity) using units of seconds.- Parameters:
timeGranularityInSeconds
- an integer value that specifies the granularity as a number of seconds Valid values of timeGranularityInSeconds can only either be one of the following four values:1 HecTime.SECOND_GRANULARITY 60 HecTime.MINUTE_GRANULARITY 3600 HecTime.HOUR_GRANULARITY 86400 HecTime.DAY_GRANULARITY
-
setTimeGranularity
public void setTimeGranularity(int baseGranularity) Sets or changes the time resolution (granularity).- Parameters:
baseGranularity
- an HecTime CONSTANT that specifies the base granularity or the resolution of the time to the nearest:Second: HecTime.SECOND_GRANULARITY Minute: HecTime.MINUTE_GRANULARITY Hour: HecTime.HOUR_GRANULARITY Day: HecTime.DAY_GRANULARITY
-
setTimeIncrement
Deprecated.Sets or changes the time resolution (granularity)- Parameters:
baseGranularity
- an HecTime CONSTANT that specifies the base granularity or the resolution of the time to the nearest:Second: HecTime.SECOND_GRANULARITY Minute: HecTime.MINUTE_GRANULARITY Hour: HecTime.HOUR_GRANULARITY Day: HecTime.DAY_GRANULARITY getTimeGranularityInSeconds
public int getTimeGranularityInSeconds()Gets the time resolution in units of seconds- Returns:
- time granularity (resolution) as one of:
1 HecTime.SECOND_GRANULARITY 60 HecTime.MINUTE_GRANULARITY 3600 HecTime.HOUR_GRANULARITY 86400 HecTime.DAY_GRANULARITY
getTimeGranularity
public int getTimeGranularity()Gets the time resolution- Returns:
- time granularity (resolution) as
Second: HecTime.SECOND_GRANULARITY Minute: HecTime.MINUTE_GRANULARITY Hour: HecTime.HOUR_GRANULARITY Day: HecTime.DAY_GRANULARITY
getTimeIncrement
Deprecated.Gets the time resolution- Returns:
- time increment (resolution) as
Second: HecTime.SECOND_GRANULARITY Minute: HecTime.MINUTE_GRANULARITY Hour: HecTime.HOUR_GRANULARITY Day: HecTime.DAY_GRANULARITY
set
public void set(int value) Set the date / time to this value (in increments) For default granularity, this is in minutes.- Parameters:
value
- increments since base (e.g., minutes since 31Dec1899).
set
public void set(int value, int julianBaseDate) set
public void set(int value, int valueGranularitySeconds, int julianBaseDate) setSeconds
public void setSeconds(long value) set
Set the date and time- Parameters:
date
- date string in a variety of formats.time
- time string in hours:minutes:seconds (colons not necessary). If resolution is not to nearest second, seconds are ignored (and not needed).- Returns:
- 0 if successful, non-zero if error.
set
Sets a string containing both the date and time- Parameters:
dateAndTime
- date followed by time, in a variety of formats (e.g., "20Jan2002 1300").- Returns:
- 0 if successful, non-zero if error.
set
Sets date / time to a Java Date object- Parameters:
javaDate
- Java Date objectminutesTimezoneOffset
- time zone offset in minutes for this date
set
Sets date / time to a Java Calendar object. Takes care of time offset and daylight savings time.- Parameters:
cal
- Java Calendar object
set
Copies a HecTime object- Parameters:
hecTime
-
setXML
Sets a string containing both the date and time in XML dateTime (ISO 8601) format.- Parameters:
dateTime
- The date and time in XML dateTime (ISO 8601) format. This format is [-]CCYY-MM-DDThh:mm:ss[{Z|{+|-}rr:nn}]- Returns:
- 0 if successful, non-zero if error.
setDate
Sets the date portion to the date string passed in- Parameters:
date
- date string in a variety of formats.- Returns:
- 0 if successful, non-zero if error.
setTime
Sets the time portion to the time string passed in (e.g., "1300")- Parameters:
time
- time string in hours:minutes:seconds (colons not necessary). If resolution is not to nearest second, seconds are ignored (and not needed).- Returns:
- 0 if successful, non-zero if error.
setCurrent
public void setCurrent()Sets the object to the current system time.setJulian
public void setJulian(int julian) Sets the date to the Hec julian date- Parameters:
julian
- days since 31Dec1899
setYearMonthDay
public void setYearMonthDay(int year, int month, int day, int minutesSinceMidnight) Sets the date to the year, month, day value and minutes past midnight- Parameters:
year
- (e.g., 2004)month
- (1-12)day
- (1-31)minutesSinceMidnight
- number of minutes (not time format) (e.g., noon is 720, not "1200")
setYearMonthDay
public void setYearMonthDay(int year, int month, int day) Sets the date to the year, month, day value and minutes past midnight Time is not changed (if not defined, left undefined)- Parameters:
year
- (e.g., 2004)month
- (1-12)day
- (1-31)
setJulian
public void setJulian(int julian, int minutesSinceMidnight) Sets the date to the Hec julian date and minutes past midnight- Parameters:
julian
- days since 31Dec1899minutesSinceMidnight
- number of minutes (not time format) (e.g., noon is 720, not "1200")
setJulian
public void setJulian(int julian, int minutesSinceMidnight, int secondsSinceMinute) Sets the date to the Hec julian date and minutes and seconds past midnight. For object using the SECOND_INCREMENT.- Parameters:
julian
- days since 31Dec1899minutesSinceMidnight
- number of minutes (not time format) (e.g., noon is 720, not "1200")secondsSinceMinute
- seconds after minute
setTimeInMillis
public void setTimeInMillis(long milliseconds) Set the time in milliseconds (same units used by Java)- Parameters:
milliseconds
- Milliseconds since Jan 19, 1970
setTimeInMillis
public void setTimeInMillis(long milliseconds, int minutesTimezoneOffset) set the time in milliseconds (same units used by Java), along with a time zone offset- Parameters:
milliseconds
- Milliseconds since Jan 19, 1970minutesTimezoneOffset
- Minute offset of the time zone
setUndefined
public void setUndefined()Set the date / time to undefinedisDefined
public boolean isDefined()Returns if the date / time is definedisDateDefined
public boolean isDateDefined()isTimeDefined
public boolean isTimeDefined()showTimeAsBeginningOfDay
public void showTimeAsBeginningOfDay(boolean showBeginning) 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:
showBeginning
- true to show midnight as 00:00 hrs, false to show midnight as 24:00 hrs (default).
getShowsTimeAsBeginningOfDay
public boolean getShowsTimeAsBeginningOfDay()Get the object setting if midnight is shown as the beginning of the next day- Returns:
- true if midnight is shown as the beginning of the next day.
date
Returns a String representation for the data part of HecTime in the format 2 June 1985.date
Returns a String representation for the date part of HecTime- Parameters:
style
- the format of the string. The possible values are as followsBase date styles 0: June 2, 1985 10: June 2, 85 100: JUNE 2, 1985 110: JUNE 2, 85 1: Jun 2, 1985 11: Jun 2, 85 101: JUN 2, 1985 111: JUN 2, 85 2: 2 June 1985 12: 2 June 85 102: 2 JUNE 1985 112: 2 JUN 85 3: June 1985 13: June 85 103: JUNE 1985 113: JUNE 85 4: 02Jun1985 14: 02Jun85 104: 02JUN1985 114: 02JUN85 5: 2Jun1985 15: 2Jun85 105: 2JUN1985 115: 2JUN85 6: Jun1985 16: Jun85 106: JUN1985 116: JUN85 7: 02 Jun 1985 17: 02 Jun 85 107: 02 JUN 1985 117: 02 JUN 85 8: 2 Jun 1985 18: 2 Jun 85 108: 2 JUN 1985 118: 2 JUN 85 9: Jun 1985 19: Jun 85 109: JUN 1985 119: JUN 85 Extended date styles -1: 6/2/85 -11: 06/02/85 -101: 6/2/1985 -111: 06/02/1985 -2: 6-2-85 -12: 06-02-85 -102: 6-2-1985 -112: 06-02-1985 -13: 1985-06-02
getJavaDate
Returns a Java Date object for this date / time- Parameters:
minutesTimezoneOffset
- minutes in the time zone offset- Returns:
- the Date object
getXMLDateTime
Returns a String for this date / time, formatted for use in XML- Parameters:
minutesTimezoneOffset
- Timezone offset in minutes. The date and time of 5 March, 2003 21:45:12 GMT would be returned as 2003-03-05T21:45:12Z if minutesTimeszoneOffset is specified as 0, and as 2003-03-05T13:45:12-08:00 if minuntesTimeOffset is specified as -480.- Returns:
- The string.
getTimeInMillis
public long getTimeInMillis()Get the date / time in milliseconds (same units that Java uses) in UTC.- Returns:
- Milliseconds since Jan 19, 1970 UTC
getTimeInMillis
public long getTimeInMillis(int minutesTimezoneOffset) Get the date / time in milliseconds (same units that Java uses)- Parameters:
minutesTimezoneOffset
- this is the number of minutes that is subtracted from the internal date to convert to UTC time.- Returns:
- Milliseconds since Jan 19, 1970, UTC
getTimeInMillis
Get the date / time in milliseconds (same units that Java uses)- Parameters:
cal
- this Calendar (and its associated TimeZone) is used to process the year, month, day, hour, minute, and second of the HecTime object- Returns:
- Milliseconds since Jan 19, 1970, UTC
getInstant
- Parameters:
zoneId
- this time zone (and its associated TimeZone) is used to process the year, month, day, hour, minute, and second of the HecTime object- Returns:
- instant - java.time object representing milliseconds since epoch
getLocalDateTime
- Returns:
- java.time object representing the timezone-less date time
getMinutes
public long getMinutes()Get Julian date / time in minutes.- Returns:
- julian date / time in minutes
getMinutes
public long getMinutes(int minutesTimezoneOffset) Get Julian date / time in minutes.- Parameters:
minutesTimezoneOffset
- this is the number of minutes that is subtracted from the internal date to convert to UTC time.- Returns:
- julian date / time in minutes
setMinutes
public void setMinutes(long minutes) Set the time in minutes since 31 Dec 1899- Parameters:
minutes
- Minutes since 31 Dec 1899
setMinutes
public void setMinutes(double minutes) Set the time in minutes since 31 Dec 1899- Parameters:
minutes
- Minutes since 31 Dec 1899
setMinutes
public void setMinutes(long minutes, int minutesTimezoneOffset) Set the time in minutes since 31 Dec 1899- Parameters:
minutes
- Minutes since 31 Dec 1899minutesTimezoneOffset
- Minute offset of the time zone
getTime
Get the time portion as user displayable string withColons == true, hh:mm:ss withColons == false, hhmm For example, if withColons, return "08:30:00", withColons == false, return "0830"- Returns:
- a string of the time
time
Get the time portion as user displayable string (For example, "08:30:00")- Returns:
- a string of the time
dateAndTime
Returns the date and time represented by this object as a string.dateAndTime
Returns a string representation of the date and time in the form of, TTTT. The date is formated based on the style parameter. hourMinutes
Returns a string representation in the form HHMMjulian
public int julian()Returns the HEC julian datesecondsSinceMidnight
public int secondsSinceMidnight()Returns the number of seconds since midnight for the time portion if time is not defined, will return UNDEFINED_VALUEminutesSinceMidnight
public int minutesSinceMidnight()Returns the number of minutes past midnight for the time portionhoursMinutesSeconds
public int hoursMinutesSeconds(intContainer hiHours, intContainer hiMinutes, intContainer hiSeconds) Obtains the time portion in int containers as hours, minutes and seconds- Parameters:
hiHours
- returns the number of hours past midnighthiMinutes
- returns the number of minutes past midnighthiSeconds
- returns the number of seconds past midnight- Returns:
- 0 if okay, -1 if time not set
yearMonthDay
Returns the date portion in int containers as years, months, days- Parameters:
hiYear
- returns the 4 digit year (e.g., 2001)hiMonth
- returns the month (Jan = 1)hiDay
- returns the day of the month- Returns:
- 0 if okay, -1 if time undefined
isoDate
public int isoDate()Generates and retuns an ISO style date as an int: YYMMDD- Returns:
- isoDate YYMMDD
isoTime
public int isoTime()Generate and return an ISO style time as an int: HHMMSS- Returns:
- iso time HHMMSS
year
public int year()Returns the 4 digit year of the date (e.g., 2002)- Returns:
- year
month
public int month()Returns the month of the date, with Jan = 1, Feb = 2- Returns:
- month
day
public int day()returns the day of the month- Returns:
- day
hour
public int hour()returns the hour of the time portion (0 - 24)- Returns:
- hour
minute
public int minute()Returns the number of minutes past the hour of the time- Returns:
- minutes
second
public int second()Returns the number of seconds past the last minute of the time- Returns:
- seconds
dayOfYear
public int dayOfYear()Returns the julian day of the year, with Jan 1 = 1, Jan 2 = 2- Returns:
- julian day of the year
dayOfWeek
public int dayOfWeek()Returns the day of the week as an int. Sunday = 1, Monday = 2, ... Saturday = 7- Returns:
- day of the week
dayOfWeekName
Returns a string containing the name of the day of the week (e.g., "Sunday", "Monday")- Returns:
setDefaultDateStyle
public void setDefaultDateStyle(int defaultDateStyle) Sets the default String representation for the date part of HecTime- Parameters:
defaultDateStyle
- the format of the string. The possible values are as follows
0: June 2, 1985 10: June 2, 85 100: JUNE 2, 1985 110: JUNE 2, 85 1: Jun 2, 1985 11: Jun 2, 85 101: JUN 2, 1985 111: JUN 2, 85 2: 2 June 1985 12: 2 June 85 102: 2 JUNE 1985 112: 2 JUN 85 3: June 1985 13: June 85 103: JUNE 1985 113: JUNE 85 4: 02Jun1985 14: 02Jun85 104: 02JUN1985 114: 02JUN85 5: 2Jun1985 15: 2Jun85 105: 2JUN1985 115: 02JUN85 6: Jun1985 16: Jun85 106: JUN1985 116: JUN85 7: 02 Jun 1985 17: 02 Jun 85 107: 02 JUN 1985 117: 02 JUN 85 8: 2 Jun 1985 18: 2 Jun 85 108: 2 JUN 1985 118: 2 JUN 85 9: Jun 1985 19: Jun 85 109: JUN 1985 119: JUN 85 Numeric Date Styles: -1: 6/2/85 -101: 6/2/1985 -2: 6-2-85 -102: 6-2-1985 -11: 06/02/85 -111: 06/02/1985 -12: 06-02-85 -112: 06-02-1985 -13: 1985-06-02 dateAndTime()
.
To return the same format asjuldat(int, int)
with style = -1000 or ≥ 1000, use the return value ofnormalizeDateStyle(int)
instead of the style itself.
getDefaultDateStyle
public int getDefaultDateStyle()toString
Returns the date and time in a user format (e.g., "10 June 2002, 13:03:42")toString
Returns the date and time in the format specified- Parameters:
dateStyle
-- Returns:
- date and time string
timeIncrement
Deprecated.use timeGranularity() instead- Returns:
- the time increment (resolution)
timeGranularity
public int timeGranularity()value
public int value()Computes and returns an int representation of the date/time Opposite of set(int). Default value is given in minutes, which is the number of minutes since 31Dec1899. if granularity is hours, this is the hours since 31Dec1899.- Returns:
convertTimeZone
Converts the HecTime from the fromTimeZone to the toTimeZone Respectes Daylight savings time- Parameters:
hecTime
- HecTimefromTimeZone
- TimeZonetoTimeZone
- TimeZone
convertTimeZone
public static void convertTimeZone(HecTime hecTime, TimeZone fromTimeZone, TimeZone toTimeZone, boolean respectDST) Converts the HecTime from the fromTimeZone to the toTimeZone User decides on respecting Daylight savings time- Parameters:
hecTime
- HecTimefromTimeZone
- TimeZonetoTimeZone
- TimeZone
convertToTimeZone
public static HecTime convertToTimeZone(int minsSince1900, TimeZone fromTimeZone, TimeZone toTimeZone) Convience function for convertTimeZone * Converts the HecTime from the fromTimeZone to the toTimeZone Respectes Daylight savings time- Parameters:
minsSince1900
- HecTimefromTimeZone
- TimeZonetoTimeZone
- TimeZone- Returns:
- HecTime
convertToTimeZone
public static HecTime convertToTimeZone(HecTime hecTime, TimeZone fromTimeZone, TimeZone toTimeZone) Convience function for convertTimeZone Returns a COPY of the time, with the original left unchanged Converts the HecTime from the fromTimeZone to the toTimeZone Respectes Daylight savings time- Parameters:
hecTime
- HecTimefromTimeZone
- TimeZonetoTimeZone
- TimeZone- Returns:
- HecTime
add
public void add(int time) Adds a given amount of time to the current time. The amount of time added depends on the Time Increment value. The default is a minutes increment- See Also:
addSeconds
public void addSeconds(int seconds) addMinutes
public void addMinutes(int minutes) addHours
public void addHours(int hours) addDays
public void addDays(int days) add
Add an HecTime to this object (adds the times together)- Parameters:
time
-
subtract
Subtract an HecTime from this date / time- Parameters:
time
- HecTime to subtract
equalTo
Determine if two HecTime object contain equal times- Parameters:
time
- HecTime to compare to- Returns:
- true if equal, false if not equal
notEqualTo
Determine if two HecTime object contain equal times- Parameters:
time
- HecTime to compare to- Returns:
- false if equal, false if equal
greaterThan
Determine if this object has a time greater than the one passed in- Parameters:
time
- HecTime to compare to- Returns:
- true if greater than, false if not
greaterThanEqualTo
Determine if this object has a time greater than or equal to the one passed in- Parameters:
time
- HecTime to compare to- Returns:
- true if greater or equal than, false if not
lessThan
Determine if this object has a time less than the one passed in- Parameters:
time
- HecTime to compare to- Returns:
- true if less than, false if not
lessThanEqualTo
Determine if this object has a time less than or equal to the one passed in- Parameters:
time
- HecTime to compare to- Returns:
- true if less than or equal to, false if not
compareTimes
Compares this time with input time.- Parameters:
time
-- Returns:
- 0 if times are equal; -1 if this time is undefined or less than input time; 1 if this time is greater than input time or input time is undefined
increment
public void increment(int numberPeriods, int minutesInPeriod) Add a number of time periods to this date / time- Parameters:
numberPeriods
- number of periods to increment byminutesInPeriod
- number of minutes in each period
incrementSecs
public void incrementSecs(int numberPeriods, int secondsInPeriod) computeNumberIntervals
Get the number of periods between two times (Heclib nopers function)- Parameters:
otherTime
- other HecTime to compute betweenintervalInMins
- number of minutes in each period- Returns:
computeNumberIntervalsSecs
computeNumberIntervals
public static int computeNumberIntervals(int startTimeMins, int endTimeMins, int intervalInMins) Get the number of periods between two times given in minutes (Heclib nopers function)- Parameters:
startTimeMins
- First time in minutesendTimeMins
- time to compute number betweenintervalInMins
- number of minutes in each period- Returns:
- number of intervals between two times Accounts for intervals that are not constant (such as months that have a varying number of days.
subtract
public void subtract(int time) Subtracts a given amount of time to the current time. The amount of time subtracted depends on the Time Increment value. The default is a minutes increment- See Also:
subtractSeconds
public void subtractSeconds(int seconds) subtractMinutes
public void subtractMinutes(int minutes) subtractHours
public void subtractHours(int hours) subtractDays
public void subtractDays(int days) cleanTime
public void cleanTime()cleanTime
protected void cleanTime(int[] times) getIntervalOffset
public int getIntervalOffset(int intervalMinutes) Compute the time offset from the provided time interval in minutes, for standard intervals used in DSS. For example, if the interval is 60 (1 hour), and the time is 12:34, the offset returned will be 34adjustToIntervalOffset
public void adjustToIntervalOffset(int intervalMinutes, int offset) Adjust the time to be at the interval offset (in minutes) provided. for standard intervals used in DSS. For example, if the interval is 60 (1 hour), and the time is 12:34 (the offset is 34), setting an offset to 0 will change the time to 13:00. (For 1 hour data, the valid times for this interval are from 12:01 to 13:00, so the adjustment will not be to 12:00.)getTimeWindow
A general purpose function to take a users time window input line, and compute a starting time and ending time For example "20May95 1200 13Jan97 0500" or "t-5d, t" The start time and end time are adjusted if specified (e.g., "-5D +2H") Implements Heclib getime routine- Parameters:
userLine
- input user linestartTime
- returns (adjusted) start time of the time windowendTime
- returns end time- Returns:
- 0 if okay, -1 non-zero if failure
getime
public static void getime(String line, int[] juls, int[] istime, int[] jule, int[] ietime, int[] status) Obtains a time window from a program command line input in the local time zone- Parameters:
line
- (input) The program command line containing the users time window input.juls
- (input/output) The starting Julian date of the time window, in days since December 31, 1899. This is changed (or not changed) according to the input on CLINE. If the time window is cleared, JULS is set to HecTime.UNDEFINED_VALUE.istime
- (input/output) The starting time of the time window, in minutes past midnight (for midnight ISTIME is 1440, not zero). If the time window is cleared, ISTIME is set to -1.jule
- (input/output) The ending Julian date of the time window, in days since December 31, 1899. If the time window is cleared, JULE is set to HecTime.UNDEFINED_VALUE.ietime
- (input/output) The ending time of the time window, in minutes past midnight. If the time window is cleared, IETIME is set to -1.status
- (output) A status parameter. If status is returned as zero, the time window was set without error. If status is returned as one, the time window was cleared. If status is returned as negative one, some error occurred and the time window was cleared.
getime
public static void getime(String line, int[] juls, int[] istime, int[] jule, int[] ietime, String tzId, int[] status) Obtains a time window from a program command line input.- Parameters:
line
- (input) The program command line containing the users time window input.juls
- (input/output) The starting Julian date of the time window, in days since December 31, 1899. This is changed (or not changed) according to the input on CLINE. If the time window is cleared, JULS is set to HecTime.UNDEFINED_VALUE.istime
- (input/output) The starting time of the time window, in minutes past midnight (for midnight ISTIME is 1440, not zero). If the time window is cleared, ISTIME is set to -1.jule
- (input/output) The ending Julian date of the time window, in days since December 31, 1899. If the time window is cleared, JULE is set to HecTime.UNDEFINED_VALUE.ietime
- (input/output) The ending time of the time window, in minutes past midnight. If the time window is cleared, IETIME is set to -1.tzId
- (input) Specifies the time window of the time zone. If null then use default time zone.status
- (output) A status parameter. If status is returned as zero, the time window was set without error. If status is returned as one, the time window was cleared. If status is returned as negative one, some error occurred and the time window was cleared.
idaywk
public static int idaywk(int jul) Returns integer day of week.- Parameters:
jul
- (input) julian day where Jan 1, 1900 is day 1- Returns:
- 1 = Sunday, 2 = Monday, etc
jliymd
jliymd
public static int jliymd(int jul, int[] ymd) iymdjl
public static int iymdjl(int intYear, int intMonth, int intDay) Returns the Julian date in days since 31 December 1899 for an integer date passed in the form of year, month, day- Parameters:
intYear
- (input) The year portion of the date. This can either be a two digit or four digit number. For years prior to 1900, a four digit number isrequired.intMonth
- (input) The integer month portion of the date (e.g., 1 corresponds to January, 2 to February, etc). This must be a number between 1 and 12.intDay
- (input) The integer day of the date. This must be a number between 1 and 31.- Returns:
- the julian date, in days since 31 December 1899. HecTime.UNDEFINED_VALUE is returned if an illegal date was passed.
yearMonthDayToJulian
public static int yearMonthDayToJulian(int year, int month, int day) julianToYearMonthDay
public static int julianToYearMonthDay(int julian, intContainer year, intContainer month, intContainer day) addCentury
public static int addCentury(int intYear) This takes a two digit year and adds the "correct" centuryA two digit year means it is the year that falls within the range of 90 years back (from now) through 10 year forward.
- Parameters:
intYear
- (input) Two digit year that is to be converted to a four digit year- Returns:
- Four digit year based on two digit input (intYear)
isLeap
public static boolean isLeap(int year) Checks if a given year is a leap year- Parameters:
year
- (Year to test)- Returns:
- true if it is a leap year, false if it is not
maxDay
public static int maxDay(int year, int month) Returns the last day of a month- Parameters:
year
- The year of the month to return the last day for, in case the month is 2month
- The month of the year (1..12) to return the last day for- Returns:
- The last day of the month (28, 29, 30, or 31)
datjul
Takes a character date, in a variety of styles, and converts it into a Julian date in days since December 31, 1899.- Parameters:
charDate
- (input) A character string containing the date to be converted.julian
- (output) The Julian date of charDate, in days since December 31, 1899.- Returns:
- errorCode (output) A status parameter. Zero indicates the date was converted. -1 indicates an invalid charDate and julian will be returned as HecTime.UNDEFINED_VALUE.
datjul
Takes a character date, in a variety of styles, and converts it into a Julian date in days since December 31, 1899.- Parameters:
charDate
- (input) A character string containing the date to be converted.julian
- (output) The Julian date of charDate, in days since December 31, 1899.errorCode
- (output) A status parameter. Zero indicates the date was converted. -1 indicates an invalid charDate and julian will be returned as HecTime.UNDEFINED_VALUE.
juldat
Takes a Julian date and a date style code and returns a string of the date in the style requested.- Parameters:
julian
- (input) The Julian datestyle
- (input) The date style code. Seedate(int)
for style descriptions.- Returns:
- The string representation of the Julian date in the date style requested
ymddat
Takes a date and a date style code and returns a string of the date in the style requested.- Parameters:
ymd
- (input) The date in the form of year, month, and daystyle
- (input) The date style codeerr
- (output) A status code indicating success (0) or failure (-1)- Returns:
- The string representation of the Julian date in the date style requested
datymd
public static void datymd(String charDate, intContainer year, intContainer month, intContainer day, intContainer errorCode) Takes a character date, in a variety of styles, and converts it into an integer year-month-day style date.- Parameters:
charDate
- (Input) A character string containing the date to be converted. If no year is provided, the current year is returned. If no day is provided, the first of the month is returned (a month must be given).year
- (Output) The year of the date. This will be a four digit year (e.g., 1982 instead of 82). If no year is given, the current year will be returned.month
- (Output) The month number of the date provided (January is 1, February is 2, etc.).day
- (Output) The day of the date. If no day is given, the first of the month is returned.errorCode
- (Output) A status parameter indicating the successfulness of the conversion. Zero is returned if the date was converted. -1 is returned if an invalid date was given.
datymd
Takes a character date, in a variety of styles, and converts it into an integer year-month-day style date.- Parameters:
charDate
- (Input) A character string containing the date to be converted. If no year is provided, the current year is returned. If no day is provided, the first of the month is returned (a month must be given).ymd
- (Output) ymd[0] is the year of the date. This will be a four digit year (e.g., 1982 instead of 82). If no year is given, the current year will be returned. ymd[1] is the month number of the date provided (January is 1, February is 2, etc.). ymd[2] is the day of the date. If no day is given, the first of the month is returned.- Returns:
- A status parameter indicating the successfulness of the conversion. Zero is returned if the date was converted. -1 is returned if an invalid date was given.
ihm2m
Takes a character string containing a twenty-four hour military style clock time (e.g., '1630'), and converts it into minutes past midnight.- Parameters:
time
- (Input) A character string containing the twenty-four hour clock time (e.g., '1422')- Returns:
- An integer number returned with time converted to minutes past midnight. If an illegal time was passed a -1 is returned.
inctim
public static int inctim(int interval, int unitFlag, int numPeriods, int startJulian, int startTime, intContainer endJulian, intContainer endTime) increments a Julian date and time a specified number of periods, based on a given time interval. This implementation provides backward compatibility with the original FORTRAN inctim.- Parameters:
interval
- (input) The time interval in either minutes or days corresponding to the number of periods to increment the date and time by.unitFlag
- (input) Indicates the units of interval. unitFlag = 0 indicates interval is in minutes, unitFlag = 1 indicates interval is in days.numPeriods
- (input) The number of periods to increment the date and time by. May be a negative number to decrement the date and time.startJulian
- (input) The starting Julian date, in days since December 31, 1899.startTime
- (input) The starting time, in minutes past midnight.endJulian
- (output) The incremented Julian date, in days since December 31, 1899.endTime
- (output) The incremented time, in minutes past midnight.- Returns:
- A dummy variable provided for compatibility reasons. Will always return a value of zero.
inctim
public static void inctim(int interval, int numPeriods, int startJulian, int startTime, int[] endJulian, int[] endTime) increments a Julian date and time a specified number of periods, based on a given time interval.- Parameters:
interval
- (input) The time interval in minutes corresponding to the number of periods to increment the date and time by.numPeriods
- (input) The number of periods to increment the date and time by. May be a negative number to decrement the date and time.startJulian
- (input) The starting Julian date, in days since December 31, 1899.startTime
- (input) The starting time, in minutes past midnight.endJulian
- (output) The incremented Julian date, in days since December 31, 1899.endTime
- (output) The incremented time, in minutes past midnight.
datcln
public static void datcln(int julianIn, int timeIn, int[] julianOut, int[] timeOut) This method cleans up the date and minutes so that timeOut is never greater than 1440 minutes.- Parameters:
julianIn
- (input) Julian date inputtimeIn
- (input) Minutues accompanying julianInjulianOut
- (output) revised julian datetimeOut
- (output) revised minutes accompanying julianOut
zofset
public static void zofset(int[] julian, int[] iTime, int interval, int iFlag, int[] iOffset) Determine the time offset for regular interval time series data- Parameters:
julian
- (input/output) The date, in hec julian daysiTime
- (input/output) The time, in minutes past midnightinterval
- (input) The time interval, in minutesiFlag
- (input) 0 - Only compute offset 1 - Compute offset, and adjust julian and iTime to the standard time 2 - Adjust julian and iTime according to iOffset (after adjusting to standard, first)iOffset
- (input/output) Offset in minutes
nopers
public static int nopers(int interval, int startJulian, int startTime, int endJulian, int endTime) Given two dates and times, and a time interval, the method NOPERS will determine the number of periods between them. This is the inverse function of method inctim. This function is used by the other nopers function to maintain compatibility. The difference is the unitFlag variable which changes the units to days or minutes.- Parameters:
interval
- The time interval corresponding to the number of periods to determine.startJulian
- The julian date of the start of the time window, in days since December 31, 1899.startTime
- The starting time, in minutes past midnight.endJulian
- The julian date of the end of the time window, in days since December 31, 1899.endTime
- The ending time, in minutes past midnight.
nopers
public static int nopers(int interval, int unitFlag, int startJulian, int startTime, int endJulian, int endTime) Given two dates and times, and a time interval, the method NOPERS will determine the number of periods between them. This is the inverse function of method inctim. This function uses the other nopers function to maintain compatibility.- Parameters:
interval
- The time interval corresponding to the number of periods to determine.unitFlag
- Indicates the units of interval. If interval is given in minutes (the typical case), set unitFlag to 0. If interval is given in days, set unitFlag to 1.startJulian
- The julian date of the start of the time window, in days since December 31, 1899.startTime
- The starting time, in minutes past midnight.endJulian
- The julian date of the end of the time window, in days since December 31, 1899.endTime
- The ending time, in minutes past midnight.
systim
This method returns the current julian date and time (in minutes or seconds)- Parameters:
julian
- (Output) HEC Julian Datetime
- (Output) Number of minutes or seconds since midnightuseMinutes
- (Input) Whether time should be in minutes (true) or seconds (false)tzId
- (Input) The time zone to use. If null, use default time zone
systim
public static void systim(int[] julian, int[] seconds) This method returns a julian date and the number of seconds since midnight in the current time zone- Parameters:
julian
- (Output) HEC Julian Dateseconds
- (Output) Number of seconds since midnight
curtim
public static void curtim(int[] julian, int[] minutes) This method returns a julian date and the number of minutes since midnight in the current time zone- Parameters:
julian
- (Output) HEC Julian Dateminutes
- (Output) Number of minutes since midnight
m2ihm
Generates a four-character hour/minute string from minutes since midnight. Minutes of 140 would generate a string of "0220" and return a value of 220. Has the same behavior as a JNI call to Hec_m2ihm()- Parameters:
minutes
- the minutes since midnight, must be between 0 and 1440 inclusivehourMinutes
- receives the generated hour/minute string- Returns:
- the generated hour/minute string as an integer value, or -1 on error
ihm2m_2
Version of ihm2m that has the same behavior as a JNI call to Hec_ihm2m. That behavior:- collects all digits interspersed in the string into a string of digits only
- converts the digit string into an integer value
- returns 60 * (value / 100) + (value % 100) as the interpreted minutes
- Parameters:
hourMinutes
- the string with digits. Would normally be a 0-4 digit string of hour/minute but see see behavior specified above- Returns:
- the number of minutes hourMinutes contains digits
- -1 if hourMinutes is empty or contains only whitespace
- 0 if hourMinutes contains non-whitespace bug no digits
normalizeDateStyle
public static int normalizeDateStyle(int style) Returns a valid date style based on an input style.- Parameters:
style
- the input style- input styles < -10 are normalized to -11 except for -112, -111, -102, -101, -13, -12, & -11 which are valid
- input styles ≥ -10 and < -2 are normalized to -1
- input styles ≥ -2 and < 20 are are valid
- input styles ≥ 20 and < 100 are normalized to 10 + the last digit of the style (e.g., 63 => 13)
- input styles ≥ 100 and < 120 are valid
- input styles > 120 are normalized to 110 + the last digit of the style (e.g., 263 => 113)
juldat(int, int)
with that style, while setting the style of an HecTime object (viasetDefaultDateStyle(int)
ordateAndTime(int)
) specifies returning only the date portion (style ≥ 1000) or the time portion (style = -1000).Base date styles 0: June 2, 1985 10: June 2, 85 100: JUNE 2, 1985 110: JUNE 2, 85 1: Jun 2, 1985 11: Jun 2, 85 101: JUN 2, 1985 111: JUN 2, 85 2: 2 June 1985 12: 2 June 85 102: 2 JUNE 1985 112: 2 JUN 85 3: June 1985 13: June 85 103: JUNE 1985 113: JUNE 85 4: 02Jun1985 14: 02Jun85 104: 02JUN1985 114: 02JUN85 5: 2Jun1985 15: 2Jun85 105: 2JUN1985 115: 2JUN85 6: Jun1985 16: Jun85 106: JUN1985 116: JUN85 7: 02 Jun 1985 17: 02 Jun 85 107: 02 JUN 1985 117: 02 JUN 85 8: 2 Jun 1985 18: 2 Jun 85 108: 2 JUN 1985 118: 2 JUN 85 9: Jun 1985 19: Jun 85 109: JUN 1985 119: JUN 85 Extended date styles -1: 6/2/85 -11: 06/02/85 -101: 6/2/1985 -111: 06/02/1985 -2: 6-2-85 -12: 06-02-85 -102: 6-2-1985 -112: 06-02-1985 -13: 1985-06-02
compareTo
compareTo- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- Object- Returns:
- int
clone
main
-
getTimeGranularity()