public final class Tstamp extends Object
Modifier and Type | Method and Description |
---|---|
static int |
daysBetween(XMLGregorianCalendar day1,
XMLGregorianCalendar day2)
Returns the number of days between time1 and time2.
|
static long |
diff(XMLGregorianCalendar time1,
XMLGregorianCalendar time2)
Returns differences between time1 and time2 in milliseconds.
|
static boolean |
equal(XMLGregorianCalendar time1,
XMLGregorianCalendar time2)
Returns true if time1 equals time2.
|
static List<XMLGregorianCalendar> |
getNTimestampList(int n,
XMLGregorianCalendar startTime,
XMLGregorianCalendar endTime)
Produces a list of n + 1 XMLGregorianCalendar instances that span the given
time interval by dividing the interval by n.
|
static List<XMLGregorianCalendar> |
getTimestampList(XMLGregorianCalendar startTime,
XMLGregorianCalendar endTime,
int intervalMinutes)
Helper function that prepares a List timestamps, between the start time and
end time, at the given sampling interval.
|
static boolean |
greaterThan(String timeString1,
String timeString2)
Returns true if timeString1 > timeString2.
|
static boolean |
greaterThan(XMLGregorianCalendar time1,
XMLGregorianCalendar time2)
Returns true if time1 > time2.
|
static boolean |
inBetween(XMLGregorianCalendar start,
XMLGregorianCalendar tstamp,
XMLGregorianCalendar end)
Returns true if tstamp is equal to or between start and end.
|
static XMLGregorianCalendar |
incrementDays(XMLGregorianCalendar tstamp,
int days)
Returns a new XMLGregorianCalendar corresponding to the passed tstamp
incremented by the number of days.
|
static XMLGregorianCalendar |
incrementHours(XMLGregorianCalendar tstamp,
int hours)
Returns a new XMLGregorianCalendar corresponding to the passed tstamp
incremented by the number of hours.
|
static XMLGregorianCalendar |
incrementMilliseconds(XMLGregorianCalendar tstamp,
long milliseconds)
Returns a new XMLGregorianCalendar corresponding to the passed tstamp
incremented by the number of milliseconds.
|
static XMLGregorianCalendar |
incrementMinutes(XMLGregorianCalendar tstamp,
int minutes)
Returns a new XMLGregorianCalendar corresponding to the passed tstamp
incremented by the number of minutes.
|
static XMLGregorianCalendar |
incrementSeconds(XMLGregorianCalendar tstamp,
int seconds)
Returns a new XMLGregorianCalendar corresponding to the passed tstamp
incremented by the number of seconds.
|
static boolean |
isTimestamp(String lexicalRepresentation)
Returns true if the passed string can be parsed into an
XMLGregorianCalendar object.
|
static boolean |
isTodayOrLater(XMLGregorianCalendar timestamp)
Returns true if the passed timestamp indicates some time today or some time
in the future.
|
static boolean |
isYesterdayOrLater(XMLGregorianCalendar timestamp)
Returns true if the passed timestamp indicates some time yesterday or some
time in the future.
|
static boolean |
lessThan(XMLGregorianCalendar time1,
XMLGregorianCalendar time2)
Returns true if time1 < time2.
|
static XMLGregorianCalendar |
makeTimestamp()
Returns an XMLGregorianCalendar corresponding to the current time.
|
static XMLGregorianCalendar |
makeTimestamp(long timeInMillis)
Converts the specified time in milliseconds into a
javax.xml.datatype.XMLGregorianCalendar.
|
static XMLGregorianCalendar |
makeTimestamp(String rep)
Returns an XMLGregorianCalendar, given its string representation.
|
static XMLGregorianCalendar |
makeTimestamp(Timestamp tstamp)
Converts a javax.sql.Timestamp into a
javax.xml.datatype.XMLGregorianCalendar.
|
static Timestamp |
makeTimestamp(XMLGregorianCalendar calendar)
Returns a new java.sql.Timestamp created from a
javax.xml.datatype.XMLGregorianCalendar.
|
static List<XMLGregorianCalendar> |
sort(Collection<XMLGregorianCalendar> tstamps)
Returns a newly created sorted list of tstamps from the passed collection.
|
public static boolean isTimestamp(String lexicalRepresentation)
lexicalRepresentation
- The string representation.public static XMLGregorianCalendar makeTimestamp(String rep) throws Exception
rep
- The string representation.Exception
- If the string cannot be parsed into a timestamp.public static XMLGregorianCalendar makeTimestamp(Timestamp tstamp)
tstamp
- The javax.sql.Timestamppublic static XMLGregorianCalendar makeTimestamp(long timeInMillis)
timeInMillis
- the specified time in milliseconds to convert.public static XMLGregorianCalendar incrementDays(XMLGregorianCalendar tstamp, int days)
tstamp
- The base date and time.days
- The number of days to increment. This can be a negative number.public static XMLGregorianCalendar incrementHours(XMLGregorianCalendar tstamp, int hours)
tstamp
- The base date and time.hours
- The number of hours to increment. This can be a negative
number.public static XMLGregorianCalendar incrementMinutes(XMLGregorianCalendar tstamp, int minutes)
tstamp
- The base date and time.minutes
- The number of minutes to increment. This can be a negative
number.public static XMLGregorianCalendar incrementSeconds(XMLGregorianCalendar tstamp, int seconds)
tstamp
- The base date and time.seconds
- The number of seconds to increment. This can be a negative
number.public static XMLGregorianCalendar incrementMilliseconds(XMLGregorianCalendar tstamp, long milliseconds)
tstamp
- The base date and time.milliseconds
- The number of milliseconds to increment. This can be a
negative number.public static Timestamp makeTimestamp(XMLGregorianCalendar calendar)
calendar
- The XML timestamp.public static XMLGregorianCalendar makeTimestamp()
public static boolean inBetween(XMLGregorianCalendar start, XMLGregorianCalendar tstamp, XMLGregorianCalendar end)
start
- The start time.tstamp
- The timestamp to test.end
- The end time.public static boolean greaterThan(XMLGregorianCalendar time1, XMLGregorianCalendar time2)
time1
- The first time.time2
- The second time.public static int daysBetween(XMLGregorianCalendar day1, XMLGregorianCalendar day2)
day1
- The first day.day2
- The second day.public static boolean greaterThan(String timeString1, String timeString2)
timeString1
- The first time.timeString2
- The second time.public static boolean lessThan(XMLGregorianCalendar time1, XMLGregorianCalendar time2)
time1
- The first time.time2
- The second time.public static boolean equal(XMLGregorianCalendar time1, XMLGregorianCalendar time2)
time1
- The first time.time2
- The second time.public static long diff(XMLGregorianCalendar time1, XMLGregorianCalendar time2)
time1
- Start.time2
- End.public static boolean isTodayOrLater(XMLGregorianCalendar timestamp)
timestamp
- The timestamp of interest.public static boolean isYesterdayOrLater(XMLGregorianCalendar timestamp)
timestamp
- The timestamp of interest.public static List<XMLGregorianCalendar> sort(Collection<XMLGregorianCalendar> tstamps)
tstamps
- The timestamps to be sorted.public static List<XMLGregorianCalendar> getTimestampList(XMLGregorianCalendar startTime, XMLGregorianCalendar endTime, int intervalMinutes)
startTime
- The start of the range requested.endTime
- The start of the range requested.intervalMinutes
- The sampling interval requested in minutes.public static List<XMLGregorianCalendar> getNTimestampList(int n, XMLGregorianCalendar startTime, XMLGregorianCalendar endTime)
n
- The number of timestamps to generate.startTime
- The start of the interval.endTime
- The end of the interval.Copyright © 2015 Collaborative Software Development Laboratory. All rights reserved.