Package com.aoindustries.sql
Class SQLUtility
- java.lang.Object
-
- com.aoindustries.sql.SQLUtility
-
public class SQLUtility extends Object
SQL utilities.- Author:
- AO Industries, Inc.
-
-
Field Summary
Fields Modifier and Type Field Description static longMAX_TIMESTAMP_SECONDSThe maximum number of seconds in aTimestamp.static longMIN_TIMESTAMP_SECONDSThe minimum number of seconds in aTimestamp.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringformatDate(long time)static StringformatDate(long time, TimeZone timeZone)static StringformatDate(Long time)static StringformatDate(Long time, TimeZone timeZone)static StringformatDate(Date date)static StringformatDate(Date date, TimeZone timeZone)static StringformatDateTime(long time)static StringformatDateTime(long time, TimeZone timeZone)static StringformatDateTime(Long time)static StringformatDateTime(Long time, TimeZone timeZone)static StringformatDateTime(Date date)static StringformatDateTime(Date date, TimeZone timeZone)static StringformatDecimal2(int pennies)Converts a number of pennies into decimal representation.static StringformatDecimal2(long pennies)Converts a number of pennies into decimal representation.static StringformatDecimal3(int millis)Converts a number of millis into decimal representation.static StringformatDecimal3(long millis)Converts a number of millis into decimal representation.static StringformatTime(long time)static StringformatTime(long time, TimeZone timeZone)static StringformatTime(Long time)static StringformatTime(Long time, TimeZone timeZone)static StringformatTime(Date date)static StringformatTime(Date date, TimeZone timeZone)static TimestampnewTimestamp(long seconds, int nanos)Converts a number of seconds and nanoseconds into a newTimestamp.static <E extends Throwable>
TimestampnewTimestamp(long seconds, int nanos, Class<E> exceptionType)Converts a number of seconds and nanoseconds into a newTimestamp.static UnmodifiableTimestampnewUnmodifiableTimestamp(long seconds, int nanos)Converts a number of seconds and nanoseconds into a newUnmodifiableTimestamp.static <E extends Throwable>
UnmodifiableTimestampnewUnmodifiableTimestamp(long seconds, int nanos, Class<E> exceptionType)Converts a number of seconds and nanoseconds into a newUnmodifiableTimestamp.static DateparseDate(String yyyy_mm_dd)static DateparseDate(String yyyy_mm_dd, TimeZone timeZone)static TimestampparseDateTime(String dateTime)static TimestampparseDateTime(String dateTime, TimeZone timeZone)static intparseDecimal2(String decimal2)Gets the number of pennies represented by aStringcontaining a decimal(?,2) type.static intparseDecimal3(String decimal3)Gets the number of millis represented by aStringcontaining a decimal(?,3) type.static longparseLongDecimal2(String decimal2)Gets the number of pennies represented by aStringcontaining a decimal(?,2) type.static longparseLongDecimal3(String decimal3)Gets the number of millis represented by aStringcontaining a decimal(?,3) type.static voidprintTable(Object[] titles, Iterable<? extends Object[]> rows, Appendable out, boolean isInteractive, boolean[] alignRights)Prints a table.static voidprintTable(Object[] titles, Object[] values, Appendable out, boolean isInteractive, boolean[] alignRights)Deprecated.Please useprintTable(java.lang.Object[], java.lang.Iterable, java.lang.Appendable, boolean, boolean[])when possible, as it may provide for more efficiency on large datasets.static voidprintTable(Object[] titles, Collection<Object> values, Appendable out, boolean isInteractive, boolean[] alignRights)Deprecated.Please useprintTable(java.lang.Object[], java.lang.Iterable, java.lang.Appendable, boolean, boolean[])when possible, as it may provide for more efficiency on large datasets.static voidtoTimestamp(long seconds, int nanos, Timestamp ts)Converts a number of seconds and nanoseconds into a givenTimestamp.static <E extends Throwable>
voidtoTimestamp(long seconds, int nanos, Timestamp ts, Class<E> exceptionType)Converts a number of seconds and nanoseconds into a givenTimestamp.
-
-
-
Field Detail
-
MAX_TIMESTAMP_SECONDS
public static final long MAX_TIMESTAMP_SECONDS
The maximum number of seconds in aTimestamp.- See Also:
- Constant Field Values
-
MIN_TIMESTAMP_SECONDS
public static final long MIN_TIMESTAMP_SECONDS
The minimum number of seconds in aTimestamp.- See Also:
- Constant Field Values
-
-
Method Detail
-
formatDate
public static String formatDate(long time, TimeZone timeZone)
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- See Also:
CalendarUtils.formatDate(java.util.Calendar)
-
formatDate
public static String formatDate(long time)
-
formatDate
public static String formatDate(Long time, TimeZone timeZone)
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- See Also:
CalendarUtils.formatDate(java.util.Calendar)
-
formatDate
public static String formatDate(Date date, TimeZone timeZone)
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- See Also:
CalendarUtils.formatDate(java.util.Calendar)
-
parseDate
public static Date parseDate(String yyyy_mm_dd, TimeZone timeZone) throws IllegalArgumentException
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- Throws:
IllegalArgumentException- See Also:
CalendarUtils.parseDate(java.lang.String, java.util.TimeZone)
-
parseDate
public static Date parseDate(String yyyy_mm_dd) throws IllegalArgumentException
- Throws:
IllegalArgumentException- See Also:
CalendarUtils.parseDate(java.lang.String)
-
formatDateTime
public static String formatDateTime(long time, TimeZone timeZone)
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- See Also:
CalendarUtils.formatDateTime(java.util.Calendar)
-
formatDateTime
public static String formatDateTime(long time)
-
formatDateTime
public static String formatDateTime(Long time, TimeZone timeZone)
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- See Also:
CalendarUtils.formatDateTime(java.util.Calendar)
-
formatDateTime
public static String formatDateTime(Date date, TimeZone timeZone)
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- See Also:
CalendarUtils.formatDateTime(java.util.Calendar)
-
parseDateTime
public static Timestamp parseDateTime(String dateTime, TimeZone timeZone) throws IllegalArgumentException
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- Throws:
IllegalArgumentException- See Also:
CalendarUtils.parseDateTime(java.lang.String, java.util.TimeZone, com.aoindustries.util.CalendarUtils.DateTimeProducer)
-
parseDateTime
public static Timestamp parseDateTime(String dateTime) throws IllegalArgumentException
- Throws:
IllegalArgumentException- See Also:
CalendarUtils.parseDateTime(java.lang.String)
-
formatTime
public static String formatTime(long time, TimeZone timeZone)
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- See Also:
CalendarUtils.formatTime(java.util.Calendar)
-
formatTime
public static String formatTime(long time)
-
formatTime
public static String formatTime(Long time, TimeZone timeZone)
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- See Also:
CalendarUtils.formatTime(java.util.Calendar)
-
formatTime
public static String formatTime(Date date, TimeZone timeZone)
- Parameters:
timeZone- The time zone to use ornullto use the default time zone- See Also:
CalendarUtils.formatTime(java.util.Calendar)
-
formatDecimal2
public static String formatDecimal2(int pennies)
Converts a number of pennies into decimal representation.
-
formatDecimal2
public static String formatDecimal2(long pennies)
Converts a number of pennies into decimal representation.
-
parseDecimal2
public static int parseDecimal2(String decimal2)
Gets the number of pennies represented by aStringcontaining a decimal(?,2) type.
-
parseLongDecimal2
public static long parseLongDecimal2(String decimal2)
Gets the number of pennies represented by aStringcontaining a decimal(?,2) type.
-
formatDecimal3
public static String formatDecimal3(int millis)
Converts a number of millis into decimal representation.
-
formatDecimal3
public static String formatDecimal3(long millis)
Converts a number of millis into decimal representation.
-
parseDecimal3
public static int parseDecimal3(String decimal3)
Gets the number of millis represented by aStringcontaining a decimal(?,3) type.
-
parseLongDecimal3
public static long parseLongDecimal3(String decimal3)
Gets the number of millis represented by aStringcontaining a decimal(?,3) type.
-
printTable
public static void printTable(Object[] titles, Iterable<? extends Object[]> rows, Appendable out, boolean isInteractive, boolean[] alignRights) throws IOException
Prints a table.- Parameters:
titles- Optional titles to displayrows- Iterated once in non-interactive mode. Iterated twice in interactive mode (first to find widest columns, then to display output). Must provide consistent output when iterated twice for interactive mode.- Throws:
IOException
-
printTable
@Deprecated public static void printTable(Object[] titles, Collection<Object> values, Appendable out, boolean isInteractive, boolean[] alignRights) throws IOException
Deprecated.Please useprintTable(java.lang.Object[], java.lang.Iterable, java.lang.Appendable, boolean, boolean[])when possible, as it may provide for more efficiency on large datasets.- Parameters:
values- One element for each row and column- Throws:
IOException
-
printTable
@Deprecated public static void printTable(Object[] titles, Object[] values, Appendable out, boolean isInteractive, boolean[] alignRights) throws IOException
Deprecated.Please useprintTable(java.lang.Object[], java.lang.Iterable, java.lang.Appendable, boolean, boolean[])when possible, as it may provide for more efficiency on large datasets.- Parameters:
values- One element for each row and column- Throws:
IOException
-
toTimestamp
public static <E extends Throwable> void toTimestamp(long seconds, int nanos, Timestamp ts, Class<E> exceptionType) throws E extends Throwable
Converts a number of seconds and nanoseconds into a givenTimestamp.- Throws:
E extends Throwable
-
toTimestamp
public static void toTimestamp(long seconds, int nanos, Timestamp ts)Converts a number of seconds and nanoseconds into a givenTimestamp.
-
newTimestamp
public static <E extends Throwable> Timestamp newTimestamp(long seconds, int nanos, Class<E> exceptionType) throws E extends Throwable
Converts a number of seconds and nanoseconds into a newTimestamp.- Throws:
E extends Throwable
-
newTimestamp
public static Timestamp newTimestamp(long seconds, int nanos) throws IllegalArgumentException
Converts a number of seconds and nanoseconds into a newTimestamp.- Throws:
IllegalArgumentException
-
newUnmodifiableTimestamp
public static <E extends Throwable> UnmodifiableTimestamp newUnmodifiableTimestamp(long seconds, int nanos, Class<E> exceptionType) throws E extends Throwable
Converts a number of seconds and nanoseconds into a newUnmodifiableTimestamp.- Throws:
E extends Throwable
-
newUnmodifiableTimestamp
public static UnmodifiableTimestamp newUnmodifiableTimestamp(long seconds, int nanos) throws IllegalArgumentException
Converts a number of seconds and nanoseconds into a newUnmodifiableTimestamp.- Throws:
IllegalArgumentException
-
-