java.lang.Object
com.aoapps.sql.SQLUtility
SQL utilities.
- Author:
- AO Industries, Inc.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic String
formatDate
(long time) static String
formatDate
(long time, TimeZone timeZone) static String
formatDate
(Long time) static String
formatDate
(Long time, TimeZone timeZone) static String
formatDate
(Date date) static String
formatDate
(Date date, TimeZone timeZone) static String
formatDateTime
(long time) static String
formatDateTime
(long time, TimeZone timeZone) static String
formatDateTime
(Long time) static String
formatDateTime
(Long time, TimeZone timeZone) static String
formatDateTime
(Date date) static String
formatDateTime
(Date date, TimeZone timeZone) static String
formatDecimal2
(int pennies) Converts a number of pennies into decimal representation.static String
formatDecimal2
(long pennies) Converts a number of pennies into decimal representation.static String
formatDecimal3
(int millis) Converts a number of millis into decimal representation.static String
formatDecimal3
(long millis) Converts a number of millis into decimal representation.static String
formatTime
(long time) static String
formatTime
(long time, TimeZone timeZone) static String
formatTime
(Long time) static String
formatTime
(Long time, TimeZone timeZone) static String
formatTime
(Date date) static String
formatTime
(Date date, TimeZone timeZone) static Timestamp
newTimestamp
(long seconds, int nanos) Converts a number of seconds and nanoseconds into a newTimestamp
.newTimestamp
(long seconds, int nanos, Class<? extends Ex> exClass) Deprecated.newTimestamp
(long seconds, int nanos, Function<? super String, ? extends Ex> exSupplier) Converts a number of seconds and nanoseconds into a newTimestamp
.static UnmodifiableTimestamp
newUnmodifiableTimestamp
(long seconds, int nanos) Converts a number of seconds and nanoseconds into a newUnmodifiableTimestamp
.static <Ex extends Throwable>
UnmodifiableTimestampnewUnmodifiableTimestamp
(long seconds, int nanos, Class<? extends Ex> exClass) Deprecated.Please usenewUnmodifiableTimestamp(long, int, java.util.function.Function)
, typically with lambda constructor referencestatic <Ex extends Throwable>
UnmodifiableTimestampnewUnmodifiableTimestamp
(long seconds, int nanos, Function<? super String, ? extends Ex> exSupplier) Converts a number of seconds and nanoseconds into a newUnmodifiableTimestamp
.static Date
static Date
static Timestamp
parseDateTime
(String dateTime) static Timestamp
parseDateTime
(String dateTime, TimeZone timeZone) static int
parseDecimal2
(String decimal2) Gets the number of pennies represented by aString
containing a decimal(?,2) type.static int
parseDecimal3
(String decimal3) Gets the number of millis represented by aString
containing a decimal(?,3) type.static long
parseLongDecimal2
(String decimal2) Gets the number of pennies represented by aString
containing a decimal(?,2) type.static long
parseLongDecimal3
(String decimal3) Gets the number of millis represented by aString
containing a decimal(?,3) type.static void
printTable
(Object[] titles, Iterable<? extends Object[]> rows, Appendable out, boolean isInteractive, boolean[] alignRights) Prints a table.static void
printTable
(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 void
printTable
(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 void
toTimestamp
(long seconds, int nanos, Timestamp ts) Converts a number of seconds and nanoseconds into a givenTimestamp
.static <Ex extends Throwable>
voidtoTimestamp
(long seconds, int nanos, Timestamp ts, Class<? extends Ex> exClass) Deprecated.Please usetoTimestamp(long, int, java.sql.Timestamp, java.util.function.Function)
, typically with lambda constructor referencestatic <Ex extends Throwable>
voidtoTimestamp
(long seconds, int nanos, Timestamp ts, Function<? super String, ? extends Ex> exSupplier) Converts a number of seconds and nanoseconds into a givenTimestamp
.
-
Field Details
-
Method Details
-
formatDate
- Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- See Also:
-
formatDate
-
formatDate
- Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- See Also:
-
formatDate
-
formatDate
- Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- See Also:
-
formatDate
-
parseDate
- Parameters:
yyyy_mm_dd
- The date in YYYY-MM-DD format.timeZone
- The time zone to use ornull
to use the default time zone- Throws:
IllegalArgumentException
- See Also:
-
parseDate
- Parameters:
yyyy_mm_dd
- The date in YYYY-MM-DD format.- Throws:
IllegalArgumentException
- See Also:
-
formatDateTime
- Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- See Also:
-
formatDateTime
-
formatDateTime
- Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- See Also:
-
formatDateTime
-
formatDateTime
- Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- See Also:
-
formatDateTime
-
parseDateTime
public static Timestamp parseDateTime(String dateTime, TimeZone timeZone) throws IllegalArgumentException - Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- Throws:
IllegalArgumentException
- See Also:
-
parseDateTime
- Throws:
IllegalArgumentException
- See Also:
-
formatTime
- Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- See Also:
-
formatTime
-
formatTime
- Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- See Also:
-
formatTime
-
formatTime
- Parameters:
timeZone
- The time zone to use ornull
to use the default time zone- See Also:
-
formatTime
-
formatDecimal2
Converts a number of pennies into decimal representation. -
formatDecimal2
Converts a number of pennies into decimal representation. -
parseDecimal2
Gets the number of pennies represented by aString
containing a decimal(?,2) type. -
parseLongDecimal2
Gets the number of pennies represented by aString
containing a decimal(?,2) type. -
formatDecimal3
Converts a number of millis into decimal representation. -
formatDecimal3
Converts a number of millis into decimal representation. -
parseDecimal3
Gets the number of millis represented by aString
containing a decimal(?,3) type. -
parseLongDecimal3
Gets the number of millis represented by aString
containing 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 <Ex extends Throwable> void toTimestamp(long seconds, int nanos, Timestamp ts, Function<? super String, ? extends Ex> exSupplier) throws ExConverts a number of seconds and nanoseconds into a givenTimestamp
.- Throws:
Ex extends Throwable
-
toTimestamp
@Deprecated public static <Ex extends Throwable> void toTimestamp(long seconds, int nanos, Timestamp ts, Class<? extends Ex> exClass) throws Ex Deprecated.Please usetoTimestamp(long, int, java.sql.Timestamp, java.util.function.Function)
, typically with lambda constructor referenceConverts a number of seconds and nanoseconds into a givenTimestamp
.- Throws:
Ex extends Throwable
-
toTimestamp
Converts a number of seconds and nanoseconds into a givenTimestamp
. -
newTimestamp
public static <Ex extends Throwable> Timestamp newTimestamp(long seconds, int nanos, Function<? super String, ? extends Ex> exSupplier) throws ExConverts a number of seconds and nanoseconds into a newTimestamp
.- Throws:
Ex extends Throwable
-
newTimestamp
@Deprecated public static <Ex extends Throwable> Timestamp newTimestamp(long seconds, int nanos, Class<? extends Ex> exClass) throws Ex Deprecated.Please usenewTimestamp(long, int, java.util.function.Function)
, typically with lambda constructor referenceConverts a number of seconds and nanoseconds into a newTimestamp
.- Throws:
Ex extends Throwable
-
newTimestamp
Converts a number of seconds and nanoseconds into a newTimestamp
.- Throws:
IllegalArgumentException
-
newUnmodifiableTimestamp
public static <Ex extends Throwable> UnmodifiableTimestamp newUnmodifiableTimestamp(long seconds, int nanos, Function<? super String, ? extends Ex> exSupplier) throws ExConverts a number of seconds and nanoseconds into a newUnmodifiableTimestamp
.- Throws:
Ex extends Throwable
-
newUnmodifiableTimestamp
@Deprecated public static <Ex extends Throwable> UnmodifiableTimestamp newUnmodifiableTimestamp(long seconds, int nanos, Class<? extends Ex> exClass) throws Ex Deprecated.Please usenewUnmodifiableTimestamp(long, int, java.util.function.Function)
, typically with lambda constructor referenceConverts a number of seconds and nanoseconds into a newUnmodifiableTimestamp
.- Throws:
Ex 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
-
newTimestamp(long, int, java.util.function.Function)
, typically with lambda constructor reference