Package com.tangosol.io.pof
Class PofHelper
java.lang.Object
com.tangosol.util.Base
com.tangosol.io.pof.PofHelper
- All Implemented Interfaces:
PofConstants
- Direct Known Subclasses:
ExternalizableLitePofSerializer,ExternalizablePofSerializer,LoggingPofHandler,PofBufferReader,PofBufferWriter,PofParser,PofPrincipal,PortableObjectSerializer,RawDate,RawDateTime,RawDayTimeInterval,RawTime,RawTimeInterval,RawYearMonthInterval,ValidatingPofHandler,WritingPofHandler,XmlSerializablePofSerializer
Collection of helper methods for POF streams.
- Since:
- Coherence 3.2
- Author:
- cp/jh 2006.07.17
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMap implementation backed by a List of Map.Entry objects.static classImmutable Map implementation backed by a Set of Map.Entry objects.Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigDecimalThe default BigDecimal value.static final BigIntegerThe BigInteger representation of Long.MAX_VALUE.static final BigIntegerThe BigInteger representation of Long.MIN_VALUE.static final BinaryAn empty Binary value.static final boolean[]An empty array of bytes.static final byte[]An empty array of bytes.static final char[]An empty array of chars.static final CollectionAn empty (and immutable) collection.static final double[]An empty array of doubles.static final float[]An empty array of floats.static final int[]An empty array of ints.static final long[]An empty array of longs.static final Object[]An empty array of objects.static final short[]An empty array of shorts.Fields inherited from class com.tangosol.util.Base
DEFAULT_LOAD_FACTOR, LOG_ALWAYS, LOG_CONFIG, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_USFields inherited from interface com.tangosol.io.pof.PofConstants
J_BIG_DECIMAL, J_BIG_INTEGER, J_BINARY, J_BOOLEAN, J_BOOLEAN_ARRAY, J_BYTE, J_BYTE_ARRAY, J_CHAR_ARRAY, J_CHARACTER, J_COLLECTION, J_DATE, J_DATETIME, J_DOUBLE, J_DOUBLE_ARRAY, J_FLOAT, J_FLOAT_ARRAY, J_INT_ARRAY, J_INTEGER, J_LOCAL_DATE, J_LOCAL_DATETIME, J_LOCAL_TIME, J_LONG, J_LONG_ARRAY, J_MAP, J_NULL, J_OBJECT_ARRAY, J_OFFSET_DATETIME, J_OFFSET_TIME, J_QUAD, J_RAW_DATE, J_RAW_DATETIME, J_RAW_DAY_TIME_INTERVAL, J_RAW_TIME, J_RAW_TIME_INTERVAL, J_RAW_YEAR_MONTH_INTERVAL, J_SHORT, J_SHORT_ARRAY, J_SPARSE_ARRAY, J_STRING, J_TIME, J_TIMESTAMP, J_USER_TYPE, J_ZONED_DATETIME, MAX_DECIMAL128_SCALE, MAX_DECIMAL128_UNSCALED, MAX_DECIMAL32_SCALE, MAX_DECIMAL32_UNSCALED, MAX_DECIMAL64_SCALE, MAX_DECIMAL64_UNSCALED, MIN_DECIMAL128_SCALE, MIN_DECIMAL32_SCALE, MIN_DECIMAL64_SCALE, T_ARRAY, T_BOOLEAN, T_CHAR, T_CHAR_STRING, T_COLLECTION, T_DATE, T_DATETIME, T_DAY_TIME_INTERVAL, T_DECIMAL128, T_DECIMAL32, T_DECIMAL64, T_FLOAT128, T_FLOAT32, T_FLOAT64, T_IDENTITY, T_INT128, T_INT16, T_INT32, T_INT64, T_MAP, T_OCTET, T_OCTET_STRING, T_REFERENCE, T_SPARSE_ARRAY, T_TIME, T_TIME_INTERVAL, T_UNIFORM_ARRAY, T_UNIFORM_COLLECTION, T_UNIFORM_KEYS_MAP, T_UNIFORM_MAP, T_UNIFORM_SPARSE_ARRAY, T_UNKNOWN, T_YEAR_MONTH_INTERVAL, V_BOOLEAN_FALSE, V_BOOLEAN_TRUE, V_COLLECTION_EMPTY, V_FP_NAN, V_FP_NEG_INFINITY, V_FP_POS_INFINITY, V_INT_0, V_INT_1, V_INT_10, V_INT_11, V_INT_12, V_INT_13, V_INT_14, V_INT_15, V_INT_16, V_INT_17, V_INT_18, V_INT_19, V_INT_2, V_INT_20, V_INT_21, V_INT_22, V_INT_3, V_INT_4, V_INT_5, V_INT_6, V_INT_7, V_INT_8, V_INT_9, V_INT_NEG_1, V_REFERENCE_NULL, V_STRING_ZERO_LENGTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intDetermine the minimum size (in bytes) of the IEEE754 decimal type that would be capable of holding the passed value.static voidcheckDate(int nYear, int nMonth, int nDay) Validate date information.static voidcheckDayTimeInterval(int cDays, int cHours, int cMinutes, int cSeconds, int cNanos) Validate a day-time interval.static voidcheckDecimalRange(BigDecimal dec, int cBytes) Verify that the specified decimal value will fit in the specified number of bits.static voidcheckElementCount(int cElements) Verify that the number of elements is valid.static voidcheckReferenceRange(int nId) Validate a reference identifier to make sure it is in a valid range.static voidcheckTime(int nHour, int nMinute, int nSecond, int nNano) Validate time information.static voidcheckTimeInterval(int cHours, int cMinutes, int cSeconds, int cNanos) Validate a time interval.static voidcheckTimeZone(int nHourOffset, int nMinuteOffset) Check the specified timezone offset.static voidcheckType(int nType) Validate a type identifier.static voidcheckYearMonthInterval(int cYears, int cMonths) Validate a year-month interval.static NumberconvertNumber(Number number, int nJavaTypeId) Convert the passed number to the specified type.static DateConvert a date, time or date/time value to a Java Date.static intdecodeTinyInt(int n) Decode an integer value from one of the reserved single-byte combined type and value indicators.static intencodeTinyInt(int n) Encode an integer value into one of the reserved single-byte combined type and value indicators.static StringformatDate(int nYear, int nMonth, int nDay) Format a date in the form YYYY-MM-DD.static StringformatTime(int nHour, int nMinute, int nSecond, int nNano, boolean fUTC) Format a time using the simplest applicable of the following formats: HH:MM HH:MM:SS HH:MM:SS.MMM HH:MM:SS.NNNNNNNNNstatic StringformatTime(int nHour, int nMinute, int nSecond, int nNano, int nHourOffset, int nMinuteOffset) Format a time using the simplest applicable of the following formats: HH:MM(+|-)HH:MM HH:MM:SS(+|-)HH:MM HH:MM:SS.MMM(+|-)HH:MM HH:MM:SS.NNNNNNNNN(+|-)HH:MMstatic intgetJavaTypeId(Object o, PofContext ctx) Return an identifier that represents the Java type of the specified object.static intgetPofTypeId(Class clz, PofContext ctx) Return an identifier that represents the POF type of the specified class.static booleanisIntrinsicPofType(Class clz) Determine if the given class can be represented as an intrinsic POF type.static BigDecimalreadAsBigDecimal(ReadBuffer.BufferInput in, int nType) Read a value of the specified encoding from the POF stream and convert it to a BigDecimal.static BigIntegerreadAsBigInteger(ReadBuffer.BufferInput in, int nType) Read a value of the specified encoding from the POF stream and convert it to a BigInteger.static charreadAsChar(ReadBuffer.BufferInput in, int nType) Read a value of the specified encoding from the POF stream and convert it to a char.static doublereadAsDouble(ReadBuffer.BufferInput in, int nType) Read a value of the specified encoding from the POF stream and convert it to a double.static floatreadAsFloat(ReadBuffer.BufferInput in, int nType) Read a value of the specified encoding from the POF stream and convert it to a float.static intreadAsInt(ReadBuffer.BufferInput in, int nType) Read a value of the specified encoding from the POF stream and convert it to an integer.static longreadAsLong(ReadBuffer.BufferInput in, int nType) Read a value of the specified encoding from the POF stream and convert it to a long.static RawQuadreadAsQuad(ReadBuffer.BufferInput in, int nType) Read a value of the specified encoding from the POF stream and convert it to a quad.static BigDecimalreadBigDecimal(ReadBuffer.BufferInput in, int cBytes) Read an IEEE754 value from the passed DataInput and convert it to a Java BigDecimal.static BigIntegerRead a BigInteger value from the passed DataInput.static charRead a "char" value from the passed DataInput.static LocalDateRead a LocalDate value from a POF stream.static LocalDateTimeRead a LocalDateTime value from a POF stream.static LocalTimeRead a LocalTime value from a POF stream.static OffsetDateTimeRead a OffsetDateTime value from a POF stream.static OffsetTimeRead a OffsetTime value from a POF stream.static RawQuadRead a quad (a 128-bit base-2 IEEE754 value) from the passed DataInput and convert it to a RawQuad.static RawDateRead a RawDate value from a POF stream.static RawTimeRead a RawTime value from a POF stream.static <T> T[]resizeArray(T[] aoOld, int cNew) Expand the passed array to contain the specified number of elements.static voidskipPackedInts(ReadBuffer.BufferInput in, int c) Skip the specified number of packed integers in the passed POF stream.static voidskipUniformValue(ReadBuffer.BufferInput in, int nType) Within the POF stream, skip the next POF value of the specified type.static voidWithin the POF stream, skip the next POF value.static voidwriteBigDecimal(WriteBuffer.BufferOutput out, BigDecimal dec, int cBytes) Write a BigDecimal to the passed DataOutput stream as a decimal value.static voidWrite a BigInteger as a packed int.static voidwriteDate(WriteBuffer.BufferOutput out, int nYear, int nMonth, int nDay) Write a date value to a BufferOutput object.static voidwriteTime(WriteBuffer.BufferOutput out, int nHour, int nMinute, int nSecond, int nNano, int nTimeZoneType, int nHourOffset, int nMinuteOffset) Write a time value to a BufferOutput object.Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, newHashMap, newHashMap, newHashSet, newHashSet, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
Field Details
-
BIGINTEGER_MAX_LONG
The BigInteger representation of Long.MAX_VALUE. -
BIGINTEGER_MIN_LONG
The BigInteger representation of Long.MIN_VALUE. -
BIGDECIMAL_ZERO
The default BigDecimal value. -
BOOLEAN_ARRAY_EMPTY
public static final boolean[] BOOLEAN_ARRAY_EMPTYAn empty array of bytes. -
BYTE_ARRAY_EMPTY
public static final byte[] BYTE_ARRAY_EMPTYAn empty array of bytes. -
CHAR_ARRAY_EMPTY
public static final char[] CHAR_ARRAY_EMPTYAn empty array of chars. -
SHORT_ARRAY_EMPTY
public static final short[] SHORT_ARRAY_EMPTYAn empty array of shorts. -
INT_ARRAY_EMPTY
public static final int[] INT_ARRAY_EMPTYAn empty array of ints. -
LONG_ARRAY_EMPTY
public static final long[] LONG_ARRAY_EMPTYAn empty array of longs. -
FLOAT_ARRAY_EMPTY
public static final float[] FLOAT_ARRAY_EMPTYAn empty array of floats. -
DOUBLE_ARRAY_EMPTY
public static final double[] DOUBLE_ARRAY_EMPTYAn empty array of doubles. -
OBJECT_ARRAY_EMPTY
An empty array of objects. -
COLLECTION_EMPTY
An empty (and immutable) collection. -
BINARY_EMPTY
An empty Binary value.
-
-
Constructor Details
-
PofHelper
public PofHelper()
-
-
Method Details
-
getJavaTypeId
Return an identifier that represents the Java type of the specified object.- Parameters:
o- an object to determine the type ofctx- the PofContext used to determine if the object is an instance of a valid user type; must not be null- Returns:
- one of the
PofConstantsclass J_* constants
-
getPofTypeId
Return an identifier that represents the POF type of the specified class.- Parameters:
clz- the class; must not be nullctx- the PofContext used to determine the type identifier of a user type; must not be null- Returns:
- one of the
PofConstantsclass T_* constants - Throws:
IllegalArgumentException- if the user type associated with the given object is unknown to the specified PofContext
-
isIntrinsicPofType
Determine if the given class can be represented as an intrinsic POF type.- Parameters:
clz- the class; must not be null- Returns:
- true if the given class can be represented as an intrinsic POF type; false, otherwise
-
convertNumber
Convert the passed number to the specified type.- Parameters:
number- the number to convertnJavaTypeId- the Java type ID to convert to, one of the J_* enumerated values- Returns:
- the number converted to the specified type
-
convertToDate
Convert a date, time or date/time value to a Java Date.- Parameters:
o- an Object of type Date, RawDate, RawTime or RawDateTime- Returns:
- a Java Date Object
-
resizeArray
public static <T> T[] resizeArray(T[] aoOld, int cNew) Expand the passed array to contain the specified number of elements.- Type Parameters:
T- the array type- Parameters:
aoOld- the "template" array or nullcNew- the number of desired elements in the new array- Returns:
- the old array, if it was big enough, or a new array of the same type
-
decodeTinyInt
public static int decodeTinyInt(int n) Decode an integer value from one of the reserved single-byte combined type and value indicators.- Parameters:
n- the integer value that the integer is encoded as- Returns:
- an integer between -1 and 22 inclusive
-
readChar
Read a "char" value from the passed DataInput.- Parameters:
in- the DataInput object to read from- Returns:
- a char value
- Throws:
IOException- on read error
-
readBigInteger
Read a BigInteger value from the passed DataInput.- Parameters:
in- the DataInput object to read from- Returns:
- the BigInteger value
- Throws:
IOException- on read error
-
readQuad
Read a quad (a 128-bit base-2 IEEE754 value) from the passed DataInput and convert it to a RawQuad.- Parameters:
in- the DataInput object to read from- Returns:
- the quad value as a RawQuad
- Throws:
IOException- on read error
-
readBigDecimal
Read an IEEE754 value from the passed DataInput and convert it to a Java BigDecimal.- Parameters:
in- the DataInput object to read fromcBytes- the number of bytes for the IEEE754 value: 4, 8 or 16- Returns:
- the BigDecimal value
- Throws:
IOException- on read error
-
readLocalDate
Read a LocalDate value from a POF stream.- Parameters:
in- the stream containing the POF date value- Returns:
- a LocalDate object
- Throws:
IOException- on read error
-
readLocalDateTime
Read a LocalDateTime value from a POF stream.- Parameters:
in- the stream containing the POF date value- Returns:
- a LocalDateTime object
- Throws:
IOException- on read error
-
readLocalTime
Read a LocalTime value from a POF stream.- Parameters:
in- the stream containing the POF date value- Returns:
- a LocalTime object
- Throws:
IOException- on read error
-
readOffsetDateTime
Read a OffsetDateTime value from a POF stream.- Parameters:
in- the stream containing the POF date value- Returns:
- a OffsetDateTime object
- Throws:
IOException- on read error
-
readOffsetTime
Read a OffsetTime value from a POF stream.- Parameters:
in- the stream containing the POF date value- Returns:
- a OffsetTime object
- Throws:
IOException- on read error
-
readRawDate
Read a RawDate value from a POF stream.- Parameters:
in- the stream containing the POF date value- Returns:
- a RawDate object
- Throws:
IOException- on read error
-
readRawTime
Read a RawTime value from a POF stream.- Parameters:
in- the stream containing the POF time value- Returns:
- a RawTime object
- Throws:
IOException- on read error
-
readAsChar
Read a value of the specified encoding from the POF stream and convert it to a char.- Parameters:
in- the POF stream containing the valuenType- the POF type of the value- Returns:
- the POF value as an char
- Throws:
IOException- if an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a char value
-
readAsInt
Read a value of the specified encoding from the POF stream and convert it to an integer.- Parameters:
in- the POF stream containing the valuenType- the POF type of the value- Returns:
- the POF value as an integer
- Throws:
IOException- if an I/O error occurs reading the POF stream, or the POF value cannot be coerced to an integer value
-
readAsLong
Read a value of the specified encoding from the POF stream and convert it to a long.- Parameters:
in- the POF stream containing the valuenType- the POF type of the value- Returns:
- the POF value as a long
- Throws:
IOException- if an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a long value
-
readAsFloat
Read a value of the specified encoding from the POF stream and convert it to a float.- Parameters:
in- the POF stream containing the valuenType- the POF type of the value- Returns:
- the POF value as a float
- Throws:
IOException- if an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a float value
-
readAsDouble
Read a value of the specified encoding from the POF stream and convert it to a double.- Parameters:
in- the POF stream containing the valuenType- the POF type of the value- Returns:
- the POF value as a double
- Throws:
IOException- if an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a double value
-
readAsQuad
Read a value of the specified encoding from the POF stream and convert it to a quad.- Parameters:
in- the POF stream containing the valuenType- the POF type of the value- Returns:
- the POF value as a RawQuad
- Throws:
IOException- if an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a double value
-
readAsBigInteger
Read a value of the specified encoding from the POF stream and convert it to a BigInteger.- Parameters:
in- the POF stream containing the valuenType- the POF type of the value- Returns:
- the POF value as a BigInteger
- Throws:
IOException- if an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a BigInteger value
-
readAsBigDecimal
Read a value of the specified encoding from the POF stream and convert it to a BigDecimal.- Parameters:
in- the POF stream containing the valuenType- the POF type of the value- Returns:
- the POF value as a BigDecimal
- Throws:
IOException- if an I/O error occurs reading the POF stream, or the POF value cannot be coerced to a BigDecimal value
-
skipValue
Within the POF stream, skip the next POF value.- Parameters:
in- the BufferInput containing the POF stream- Throws:
IOException- on read error
-
skipUniformValue
Within the POF stream, skip the next POF value of the specified type.- Parameters:
in- the BufferInput containing the POF streamnType- the type of the value to skip- Throws:
IOException- on read error
-
skipPackedInts
Skip the specified number of packed integers in the passed POF stream.- Parameters:
in- the BufferInput containing the POF streamc- the number of packed integers to skip over- Throws:
IOException- on read error
-
writeBigInteger
Write a BigInteger as a packed int.- Parameters:
out- the DataOutput to write ton- the BigInteger value- Throws:
IOException- on write error
-
writeBigDecimal
public static void writeBigDecimal(WriteBuffer.BufferOutput out, BigDecimal dec, int cBytes) throws IOException Write a BigDecimal to the passed DataOutput stream as a decimal value.- Parameters:
out- the DataOutput to write todec- the BigDecimal valuecBytes- the number of bytes for the IEEE754 value: 4, 8 or 16- Throws:
IOException- on write error
-
encodeTinyInt
public static int encodeTinyInt(int n) Encode an integer value into one of the reserved single-byte combined type and value indicators.- Parameters:
n- an integer between -1 and 22 inclusive- Returns:
- the integer value that the integer is encoded as
-
writeDate
public static void writeDate(WriteBuffer.BufferOutput out, int nYear, int nMonth, int nDay) throws IOException Write a date value to a BufferOutput object.- Parameters:
out- the BufferOutput to write tonYear- the year number as defined by ISO8601; note the difference with the Java Date class, whose year is relative to 1900nMonth- the month number between 1 and 12 inclusive as defined by ISO8601; note the difference from the Java Date class, whose month value is 0-based (0-11)nDay- the day number between 1 and 31 inclusive as defined by ISO8601- Throws:
IOException- thrown if the passed BufferOutput object throws an IOException while the value is being written to it
-
writeTime
public static void writeTime(WriteBuffer.BufferOutput out, int nHour, int nMinute, int nSecond, int nNano, int nTimeZoneType, int nHourOffset, int nMinuteOffset) throws IOException Write a time value to a BufferOutput object.- Parameters:
out- the BufferOutput to write tonHour- the hour between 0 and 23 inclusivenMinute- the minute value between 0 and 59 inclusivenSecond- the second value between 0 and 59 inclusive (and theoretically 60 for a leap-second)nNano- the nanosecond value between 0 and 999999999 inclusivenTimeZoneType- 0 if the time value does not have an explicit time zone, 1 if the time value is UTC and 2 if the time zone has an explicit hour and minute offsetnHourOffset- the timezone offset in hours from UTC, for example 0 for BST, -5 for EST and 1 for CETnMinuteOffset- the timezone offset in minutes, for example 0 (in most cases) or 30- Throws:
IOException- thrown if the passed BufferOutput object throws an IOException while the value is being written to it
-
checkType
public static void checkType(int nType) Validate a type identifier.- Parameters:
nType- the type identifier
-
checkElementCount
public static void checkElementCount(int cElements) Verify that the number of elements is valid.- Parameters:
cElements- the number of elements in a complex data structure
-
checkReferenceRange
public static void checkReferenceRange(int nId) Validate a reference identifier to make sure it is in a valid range.- Parameters:
nId- the reference identity
-
checkDecimalRange
Verify that the specified decimal value will fit in the specified number of bits.- Parameters:
dec- the decimal valuecBytes- the number of bytes (4, 8 or 16)
-
calcDecimalSize
Determine the minimum size (in bytes) of the IEEE754 decimal type that would be capable of holding the passed value.- Parameters:
dec- the decimal value- Returns:
- the number of bytes (4, 8 or 16)
-
checkDate
public static void checkDate(int nYear, int nMonth, int nDay) Validate date information.- Parameters:
nYear- the year numbernMonth- the month numbernDay- the day number
-
checkTime
public static void checkTime(int nHour, int nMinute, int nSecond, int nNano) Validate time information.- Parameters:
nHour- the hour numbernMinute- the minute numbernSecond- the second numbernNano- the nanosecond number
-
checkTimeZone
public static void checkTimeZone(int nHourOffset, int nMinuteOffset) Check the specified timezone offset.- Parameters:
nHourOffset- the hour offsetnMinuteOffset- the minute offset
-
checkYearMonthInterval
public static void checkYearMonthInterval(int cYears, int cMonths) Validate a year-month interval.- Parameters:
cYears- the number of yearscMonths- the number of months
-
checkTimeInterval
public static void checkTimeInterval(int cHours, int cMinutes, int cSeconds, int cNanos) Validate a time interval.- Parameters:
cHours- the number of hourscMinutes- the number of minutescSeconds- the number of secondscNanos- the number of nanoseconds
-
checkDayTimeInterval
public static void checkDayTimeInterval(int cDays, int cHours, int cMinutes, int cSeconds, int cNanos) Validate a day-time interval.See http://www.builderau.com.au/architect/database/soa/SQL_basics_Datetime_and_interval_data_types/0,39024547,20269031,00.htm
- Parameters:
cDays- the number of dayscHours- the number of hourscMinutes- the number of minutescSeconds- the number of secondscNanos- the number of nanoseconds
-
formatDate
Format a date in the form YYYY-MM-DD.- Parameters:
nYear- the year numbernMonth- the month numbernDay- the day number- Returns:
- the formatted string
-
formatTime
Format a time using the simplest applicable of the following formats:- HH:MM
- HH:MM:SS
- HH:MM:SS.MMM
- HH:MM:SS.NNNNNNNNN
- Parameters:
nHour- the hour numbernMinute- the minute numbernSecond- the second numbernNano- the nanosecond numberfUTC- true for UTC, false for no time zone- Returns:
- a time String
-
formatTime
public static String formatTime(int nHour, int nMinute, int nSecond, int nNano, int nHourOffset, int nMinuteOffset) Format a time using the simplest applicable of the following formats:- HH:MM(+|-)HH:MM
- HH:MM:SS(+|-)HH:MM
- HH:MM:SS.MMM(+|-)HH:MM
- HH:MM:SS.NNNNNNNNN(+|-)HH:MM
- Parameters:
nHour- the hour numbernMinute- the minute numbernSecond- the second numbernNano- the nanosecond numbernHourOffset- the timezone offset in hoursnMinuteOffset- the timezone offset in minutes- Returns:
- a time String
-