|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectDateUtil
public abstract class DateUtil
Utility class supplying static methods. Date serialization is based on the algorithms published by Peter Baum (http://www.capecod.net/~pbaum). All date handling is done according to the W3C Schema specification, which uses a proleptic Gregorian calendar with no year 0. Note that this differs from the Java date handling, which uses a discontinuous Gregorian calendar.
modules/library/main (gt-main.jar)
Constructor Summary | |
---|---|
DateUtil()
|
Method Summary | |
---|---|
static List |
arrayListFactory()
Factory method to create a java.util.ArrayList as the
implementation of a java.util.List . |
static byte[] |
deserializeBase64(String text)
Parse base64 data from text. |
static char |
deserializeCharString(String text)
Deserialize char value from text as character value. |
static Date |
deserializeDate(String text)
Deserialize date from text. |
static Date |
deserializeDateTime(String text)
Deserialize date from general dateTime text. |
static Date |
deserializeSqlDate(String text)
Deserialize SQL date from text. |
static Time |
deserializeSqlTime(String text)
Deserialize time from text. |
static Timestamp |
deserializeTimestamp(String text)
Deserialize timestamp from general dateTime text. |
static void |
encodeChunk(int base,
byte[] byts,
StringBuffer buff)
Encode a chunk of data to base64 encoding. |
static int |
enumValue(String target,
String[] enums,
int[] vals)
Find text value in enumeration. |
protected static void |
formatTwoDigits(int value,
StringBuffer buff)
Format a positive number as two digits. |
protected static void |
formatYear(long value,
StringBuffer buff)
Format time in milliseconds to year number. |
protected static long |
formatYearMonth(long value,
StringBuffer buff)
Format time in milliseconds to year number and month number. |
protected static int |
formatYearMonthDay(long value,
StringBuffer buff)
Format time in milliseconds to year number, month number, and day number. |
protected static void |
formatYearNumber(long year,
StringBuffer buff)
Format year number consistent with W3C XML Schema definitions, using a minimum of four digits padded with zeros if necessary. |
static boolean |
isEqual(Object a,
Object b)
General object comparison method. |
static byte[] |
parseBase64(String text)
Parse base64 data from text. |
static boolean |
parseBoolean(String text)
Parse boolean value from text. |
static byte |
parseByte(String text)
Parse byte value from text. |
static char |
parseChar(String text)
Parse char value from text as unsigned 16-bit integer. |
static char |
parseCharString(String text)
Parse char value from text as character value. |
static long |
parseDate(String text)
Convert date text to Java date. |
static long |
parseDateTime(String text)
Parse general dateTime value from text. |
static double |
parseDouble(String text)
Parse double value from text. |
static float |
parseFloat(String text)
Parse float value from text. |
static int |
parseInt(String text)
Parse integer value from text. |
static long |
parseLong(String text)
Parse long value from text. |
static short |
parseShort(String text)
Parse short value from text. |
static long |
parseTime(String text,
int start,
int length)
Parse general time value from text. |
static long |
parseYear(String text)
Convert gYear text to Java date. |
static long |
parseYearMonth(String text)
Convert gYearMonth text to Java date. |
static String |
serializeBase64(byte[] byts)
Serialize byte array to base64 text. |
static String |
serializeBoolean(boolean value)
Serialize boolean value to text. |
static String |
serializeByte(byte value)
Serialize byte value to text. |
static String |
serializeChar(char value)
Serialize char value to text as unsigned 16-bit integer. |
static String |
serializeCharString(char value)
Serialize char value to text as string of length one. |
static String |
serializeDate(Date date)
Serialize date to general date text. |
static String |
serializeDate(long time)
Serialize time to general date text. |
static String |
serializeDateTime(Date date)
Serialize date to general dateTime text. |
static String |
serializeDateTime(long time)
Serialize time to general dateTime text. |
static String |
serializeDateTime(long time,
boolean zone)
Serialize time to general dateTime text. |
static String |
serializeDouble(double value)
Serialize double value to text. |
static String |
serializeFloat(float value)
Serialize float value to text. |
static String |
serializeInt(int value)
Serialize int value to text. |
static String |
serializeLong(long value)
Serialize long value to text. |
static String |
serializeShort(short value)
Serialize short value to text. |
static String |
serializeSqlDate(Date date)
Serialize SQL date to general date text. |
static String |
serializeSqlTime(Time time)
Serialize time to standard text. |
static void |
serializeTime(int time,
StringBuffer buff)
Serialize time to general time text in buffer. |
static String |
serializeTimestamp(Timestamp stamp)
Serialize timestamp to general dateTime text. |
static String |
serializeYear(Date date)
Serialize date to general gYear text. |
static String |
serializeYear(long time)
Serialize time to general gYear text. |
static String |
serializeYearMonth(Date date)
Serialize date to general gYearMonth text. |
static String |
serializeYearMonth(long time)
Serialize time to general gYearMonth text. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DateUtil()
Method Detail |
---|
public static int parseInt(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static String serializeInt(int value)
value
- int value to be serialized
public static long parseLong(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static String serializeLong(long value)
value
- long value to be serialized
public static short parseShort(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static String serializeShort(short value)
value
- short value to be serialized
public static byte parseByte(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static String serializeByte(byte value)
value
- byte value to be serialized
public static boolean parseBoolean(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static String serializeBoolean(boolean value)
value
- boolean value to be serialized
public static char parseChar(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static String serializeChar(char value)
value
- char value to be serialized
public static char parseCharString(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static char deserializeCharString(String text) throws IllegalArgumentException
text
- text to be parsed (may be null
)
IllegalArgumentException
- on parse errorpublic static String serializeCharString(char value)
value
- char value to be serialized
public static float parseFloat(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static String serializeFloat(float value)
value
- float value to be serialized
public static double parseDouble(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static String serializeDouble(double value)
value
- double value to be serialized
public static long parseYear(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static long parseYearMonth(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static long parseDate(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static Date deserializeDate(String text) throws IllegalArgumentException
null
input.
text
- text to be parsed (may be null
)
null
if passed null
input
IllegalArgumentException
- on parse errorpublic static Date deserializeSqlDate(String text) throws IllegalArgumentException
null
input.
text
- text to be parsed (may be null
)
null
if passed null
input
IllegalArgumentException
- on parse errorpublic static long parseTime(String text, int start, int length) throws IllegalArgumentException
text
- text to be parsedstart
- offset of first character of time valuelength
- number of characters in time value
IllegalArgumentException
- on parse errorpublic static long parseDateTime(String text) throws IllegalArgumentException
text
- text to be parsed
IllegalArgumentException
- on parse errorpublic static Date deserializeDateTime(String text) throws IllegalArgumentException
null
input.
text
- text to be parsed (may be null
)
null
if passed null
input
IllegalArgumentException
- on parse errorpublic static Timestamp deserializeTimestamp(String text) throws IllegalArgumentException
null
input.
text
- text to be parsed (may be null
)
null
if passed
null
input
IllegalArgumentException
- on parse errorpublic static Time deserializeSqlTime(String text) throws IllegalArgumentException
null
input.
text
- text to be parsed (may be null
)
null
if passed null
input
IllegalArgumentException
- on parse errorprotected static void formatYearNumber(long year, StringBuffer buff)
year
- number to be formattedbuff
- text formatting bufferprotected static void formatTwoDigits(int value, StringBuffer buff)
value
- number to be formatted (0
to 99
)buff
- text formatting bufferprotected static void formatYear(long value, StringBuffer buff)
value
- time in milliseconds to be converted (from 1 C.E.)buff
- text formatting bufferprotected static long formatYearMonth(long value, StringBuffer buff)
value
- time in milliseconds to be converted (from 1 C.E.)buff
- text formatting buffer
protected static int formatYearMonthDay(long value, StringBuffer buff)
value
- time in milliseconds to be converted (from 1 C.E.)buff
- text formatting buffer
public static String serializeYear(long time) throws IllegalArgumentException
time
- time to be converted, as milliseconds from January 1, 1970
IllegalArgumentException
- on conversion errorpublic static String serializeYear(Date date) throws IllegalArgumentException
date
- date to be converted
IllegalArgumentException
- on conversion errorpublic static String serializeYearMonth(long time) throws IllegalArgumentException
time
- time to be converted, as milliseconds from January 1, 1970
IllegalArgumentException
- on conversion errorpublic static String serializeYearMonth(Date date) throws IllegalArgumentException
date
- date to be converted
IllegalArgumentException
- on conversion errorpublic static String serializeDate(long time) throws IllegalArgumentException
time
- time to be converted, as milliseconds from January 1, 1970
IllegalArgumentException
- on conversion errorpublic static String serializeDate(Date date) throws IllegalArgumentException
date
- date to be converted
IllegalArgumentException
- on conversion errorpublic static String serializeSqlDate(Date date) throws IllegalArgumentException
date
- date to be converted
IllegalArgumentException
- on conversion errorpublic static void serializeTime(int time, StringBuffer buff) throws IllegalArgumentException
time
- time to be converted, as milliseconds in daybuff
- buffer for appending time text
IllegalArgumentException
- on conversion errorpublic static String serializeDateTime(long time, boolean zone) throws IllegalArgumentException
time
- time to be converted, as milliseconds from January 1, 1970zone
- flag for trailing 'Z' to be appended to indicate UTC
IllegalArgumentException
- on conversion errorpublic static String serializeDateTime(long time) throws IllegalArgumentException
time
- time to be converted, as milliseconds from January 1, 1970
IllegalArgumentException
- on conversion errorpublic static String serializeDateTime(Date date) throws IllegalArgumentException
date
- date to be converted
IllegalArgumentException
- on conversion errorpublic static String serializeTimestamp(Timestamp stamp) throws IllegalArgumentException
stamp
- timestamp to be converted
IllegalArgumentException
- on conversion errorpublic static String serializeSqlTime(Time time) throws IllegalArgumentException
time
- time to be converted
IllegalArgumentException
- on conversion errorpublic static boolean isEqual(Object a, Object b)
a
- first object to be comparedb
- second object to be compared
true
if both objects are null
, or if
a.equals(b)
; false
otherwisepublic static int enumValue(String target, String[] enums, int[] vals) throws IllegalArgumentException
target
- text to be found in enumerationenums
- ordered array of texts included in enumerationvals
- array of values to be returned for corresponding text match
positions (position returned directly if this is
null
)
IllegalArgumentException
- if target text not found in enumerationpublic static byte[] parseBase64(String text) throws IllegalArgumentException
text
- text to be parsed (may include extra characters)
IllegalArgumentException
- if invalid character in base64
representationpublic static byte[] deserializeBase64(String text) throws IllegalArgumentException
text
- text to be parsed (may be null, or include extra characters)
IllegalArgumentException
- if invalid character in base64
representationpublic static void encodeChunk(int base, byte[] byts, StringBuffer buff)
base
- starting offset within byte arraybyts
- byte data arraybuff
- buffer for encoded textpublic static String serializeBase64(byte[] byts)
byts
- byte data array
public static List arrayListFactory()
java.util.ArrayList
as the
implementation of a java.util.List
.
java.util.ArrayList
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |