List of utility methods to do SQL Time
int | compareTime(String time1, String time2) compare Time Date newDate1 = parseDate("1990-01-01 " + time1, "yyyy-MM-dd HH:mm:ss"); Date newDate2 = parseDate("1990-01-01 " + time2, "yyyy-MM-dd HH:mm:ss"); if (getMillis(newDate1) - getMillis(newDate2) > 0) return 1; else if (getMillis(newDate1) - getMillis(newDate2) < 0) return -1; return 0; |
Time | createTime(int hour, int minute, int second) Replaces deprecated java.sql.Time constructor.
primeCalendar(); CAL.get().set(Calendar.HOUR_OF_DAY, hour); CAL.get().set(Calendar.MINUTE, minute); CAL.get().set(Calendar.SECOND, second); return new Time(CAL.get().getTimeInMillis()); |
String | dateTime2str(java.sql.Date date) date Timestr if (date == null) return ""; try { return MMddYYYY_HHmmss.format(date); } catch (Exception e) { return ""; |
String | dateTimeFormat(Date date, String pattern) date Time Format String s = ""; try { SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); s = dformat.format(date); s = String.valueOf(StrToTimestamp(s, pattern)); s = s.substring(0, pattern.length()); } catch (Exception e) { return s; |
long | DateTimeSpace(String starttime, String endtime) Date Time Space SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); long starttimes = 0; long endtimes = 0; long spacetime = 0; try { starttimes = sdf.parse(starttime).getTime(); endtimes = sdf.parse(endtime).getTime(); } catch (ParseException e) { ... |
String | dateTimeToStr(java.util.Date date) date Time To Str if (date == null) { return null; } else { return (new SimpleDateFormat(SimpleDateTimeFormat)).format(date); |
Time | daytime() Gets the current time. return new Time(System.currentTimeMillis()); |
Time | deserializeSqlTime(String text) Deserialize time from text. if (text == null) { return null; } else { return new Time(parseTime(text, 0, text.length())); |
Time | double2Time(Number zahl) double Time Time t = null; if (zahl != null) { double d = (zahl.doubleValue() * (double) 3600000) - 3600000; t = new Time((long) d); return t; |
boolean | equalsTime(Time time1, Time time2) equals Time boolean result = false; if (time1 != null && time2 != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(time1); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.MONTH, 0); calendar.set(Calendar.YEAR, 1970); calendar.set(Calendar.MILLISECOND, 0); ... |