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.TimegetSqlTime(int hour, int minute, int second)
Get SQL Time(java.sql.Time) from supplied parameters
Calendar cal = Calendar.getInstance();
cal.setTime(new java.util.Date(0));
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
cal.set(Calendar.SECOND, second);
cal.set(Calendar.MILLISECOND, 0);
return getSqlTime(cal.getTime());
TimegetSQLTime(String timeString)
get SQL Time
String[] timeStrings = timeString.split(":");
int hour = Integer.parseInt(timeStrings[0]);
int minute = Integer.parseInt(timeStrings[1]);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
Time time = new Time(calendar.getTimeInMillis());
return time;
...
TimegetSQLTime(String value)
get SQL Time
Time result = null;
assert value != null : "[DSU] invalid value : " + value;
if (value != null) {
    DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss");
    result = new Time(getDate(TIME_FORMAT, value).getTime());
return result;
java.sql.TimegetSQLTimeFromString(String s)
returns a SQL Time given a formatted string
return java.sql.Time.valueOf(s);
TimegetSqlTimeFromTimeNumber(int time)
get Sql Time From Time Number
int leftover = time;
final int hour = leftover / (60 * 60 * 1000);
leftover -= hour * 60 * 60 * 1000;
final int minute = leftover / (60 * 1000);
leftover -= minute * 60 * 1000;
final int second = leftover / 1000;
leftover -= second * 1000;
final int milli = leftover;
...
StringgetSysDateTimeMillis()
get Sys Date Time Millis
String str = new Timestamp(System.currentTimeMillis()).toString();
if (str.length() >= 23) {
    return str.substring(0, 23);
} else {
    StringBuilder sb = new StringBuilder();
    sb.append(str);
    for (int i = 0; i < 23 - str.length(); i++) {
        sb.append("0");
...
DategetSystemCurrentTimeMillis()
get System Current Time Millis
return new Timestamp(System.currentTimeMillis());
longgetSystemTimeGMTToday()
get System Time GMT Today
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Timestamp today = toTimestamp(sdf.format(Calendar.getInstance().getTime()) + " 00:00:00");
return toGMTTime(today);
TimestampgetSysTime()
get Sys Time
Timestamp sys_time = new Timestamp(Calendar.getInstance().getTimeInMillis());
return sys_time;
DategetThisWeekStartTime()
get This Week Start Time
Calendar today = Calendar.getInstance();
today.set(Calendar.DAY_OF_WEEK, today.getFirstDayOfWeek());
Calendar weekFirstDay = Calendar.getInstance();
weekFirstDay.clear();
weekFirstDay.set(Calendar.YEAR, today.get(Calendar.YEAR));
weekFirstDay.set(Calendar.MONTH, today.get(Calendar.MONTH));
weekFirstDay.set(Calendar.DATE, today.get(Calendar.DATE));
return weekFirstDay.getTime();
...