Java Utililty Methods SQL Time

List of utility methods to do SQL Time

Description

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

Method

intgetIntervalDays(Date time1, Date time2)
get Interval Days
if (time1 == null || time2 == null)
    return 0;
return getIntervalDays(time1.getTime(), time2.getTime());
StringgetJoinedSysDateTime()
get Joined Sys Date Time
String str = getSysDateTime();
str = str.substring(0, 4) + str.substring(5, 7) + str.substring(8, 10) + str.substring(11, 13)
        + str.substring(14, 16) + str.substring(17, 19);
return str;
TimestampgetLastTimeOfDay(Calendar calendar)
get Last Time Of Day
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
return new Timestamp(calendar.getTimeInMillis());
TimestampgetMaxModifyTime(String path)
get Max Modify Time
List<String> filelist = getAllFileName(path);
Timestamp time = null;
for (String s : filelist) {
    File f = new File(s);
    if (time == null) {
        time = new Timestamp(f.lastModified());
    } else {
        if (time.getTime() < new Timestamp(f.lastModified()).getTime()) {
...
intgetMaxPollTime(final Connection jdbcConnection, final String tableName)
get Max Poll Time
int maxRow = 0;
Statement stmt = null;
ResultSet rs = null;
try {
    stmt = jdbcConnection.createStatement();
    String sql = MessageFormat.format("SELECT max(polltime) as maxpoll FROM {0}", tableName);
    rs = stmt.executeQuery(sql);
    if (rs.next()) {
...
java.util.DategetServerTime()
get Server Time
GregorianCalendar date = new GregorianCalendar();
return date.getTime();
TimeZonegetServerTimezone(Properties dbSettings)
Returns the Server timezone.
if (serverTimeZone == null) {
    String url = dbSettings.getProperty("hibernate.connection.url");
    String username = dbSettings.getProperty("hibernate.connection.username");
    String password = dbSettings.getProperty("hibernate.connection.password");
    Connection conn = DriverManager.getConnection(url, username, password);
    ResultSet rs = conn.createStatement()
            .executeQuery("select timestampdiff(HOUR,utc_timestamp(), current_timestamp());");
    String timediff = "";
...
StringgetSGWDateTime(long dateTime)
get SGW Date Time
dateTime = dateTime * 1000;
long sd = (dateTime - 28800000);
Date dat = new Date(sd);
return formatTime(dat);
java.sql.TimestampgetSQLDate(long datetime)
get SQL Date
return new Timestamp(datetime);
TimestampgetSQLDateTime()
Method getSQLDateTime.
Calendar caldate = Calendar.getInstance();
Timestamp t = new Timestamp(caldate.getTimeInMillis());
t.setTime(caldate.getTimeInMillis());
return t;