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

StringgetTime()
get Time
Timestamp time = new Timestamp(Calendar.getInstance().getTime().getTime());
return time.toString();
StringgetTime()
get Time
java.util.Date dt = new java.util.Date();
java.sql.Timestamp ts = new java.sql.Timestamp(dt.getTime());
String time = ts.toString();
return time.substring(0, 19);
TimegetTime(final int hour, final int minute, final int second)
Creates a java.sql.Time for a specified time in the UTC time zone.
final Calendar cal = new GregorianCalendar(UTC);
cal.clear();
cal.set(1979, 0, 1, hour, minute, second);
return new Time(cal.getTimeInMillis());
StringgetTime(GregorianCalendar cal)
Gets time in hh:mm:ss format from GregorianCalendar.
SimpleDateFormat sdf = new SimpleDateFormat(timeFormat);
Date date = cal.getTime();
return sdf.format(date);
TimegetTime(java.util.Date date)
get Time
if (date == null) {
    return currentTime();
Calendar c = Calendar.getInstance();
c.setTimeInMillis(date.getTime());
c.set(Calendar.YEAR, 1970);
c.set(Calendar.MONTH, Calendar.JANUARY);
c.set(Calendar.DAY_OF_MONTH, 1);
...
StringgetTime(long time)
Creates a timestamp using the Timestamp class.
String stamp = new Timestamp(time).toString();
return stamp.substring(0, stamp.length() - 4);
TimestampgetTime(long time)
get Time
if (time == 0 || time < 0) {
    return getCurrentTimestamp();
return new Timestamp(time);
StringgetTime(long time)
get Time
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return format.format(new Date(time));
StringgetTime(long time, boolean allowNull)
Gets the database format for a time field.
return allowNull && time == -1 ? null : new Timestamp(time).toString().substring(11, 19); 
java.sql.TimegetTime(Map map, String attr)
get Time
return (java.sql.Time) map.get(attr);