Java Utililty Methods SQL Time Create

List of utility methods to do SQL Time Create

Description

The list of methods to do SQL Time Create are organized into topic(s).

Method

java.sql.TimegetTime(Object value)
Convert an Object to a Time, without an Exception
try {
    return toTime(value);
} catch (ParseException pe) {
    pe.printStackTrace();
    return null;
java.sql.TimegetTime(Object value, int columnType)
get Time
if (value == null) {
    return null;
switch (columnType) {
case java.sql.Types.TIME: {
    return (java.sql.Time) value;
case java.sql.Types.TIMESTAMP: {
...
DategetTime(ResultSet resultSet, String columnName)
Returns a time value using a given SQL result set and column name.
Date value = null;
if (resultSet != null && columnName != null) {
    value = resultSet.getTime(columnName);
return value;
TimegetTime(ResultSet rs, String column)
get a Time from ResultSet rs with name 'column'
Time i = rs.getTime(column);
if (rs.wasNull())
    i = new Time(0);
return i;
TimestampgetTime(String time)
get Time
Timestamp timestamp = null;
try {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
    java.util.Date parsedDate = dateFormat.parse(time);
    timestamp = new java.sql.Timestamp(parsedDate.getTime());
} catch (Exception e) {
    e.printStackTrace();
return timestamp;
StringgetTimeAndDateStamp(String line)
get Time And Date Stamp
Date unixTimeStamp = new Date(Long.parseLong(line.split(" ")[0]));
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd-MM-yy, hh:mm a z");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
return sdf.format(unixTimeStamp);
TimestampgetTimeBy(int hour)
get Time By
return getTimeBy(hour, 0, 0, 0);
StringgetTimeFormat()
get Time Format
return TIME_FORMAT;
TimegetTimeFromCalendar(final Calendar calendar)
A utility to return the Time part of a calendar.
return (Time.valueOf(toTimeString(calendar)));
ListgetTimeList(ResultSet resultSet, String columnName)
Returns a list of time values using a given SQL result set and column name.
List<Date> values = null;
if (resultSet != null && columnName != null) {
    values = new ArrayList<Date>();
    while (resultSet.next()) {
        values.add(getTime(resultSet, columnName));
return values;
...