List of utility methods to do SQL Time
Date | getZeroTimeDate(Date fecha) get Zero Time Date Date res = fecha;
Calendar calendar = Calendar.getInstance();
calendar.setTime(fecha);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
res = new Date(calendar.getTime().getTime());
...
|
Boolean | isBetweenHours(Time hora, Time horaInicio, Time horaFim) is Between Hours return (hora.equals(horaInicio) || (hora.after(horaInicio) && hora.before(horaFim))
|| hora.equals(horaFim));
|
boolean | isCategoryDateOrTime(String sJavaType) is Category Date Or Time if (null == sJavaType) return false; if ("java.util.Date".equals(sJavaType)) return true; if ("java.sql.Date".equals(sJavaType)) return true; if ("java.sql.Time".equals(sJavaType)) return true; ... |
boolean | isDateTime(int type) is Date Time if (type == Types.DATE) { return true; } else { return false; |
boolean | isDateTime(String val) is Date Time if (val != null) { String str[] = val.split("\\s"); if (str.length == 2 && isDate(str[0]) && isTime(str[1])) return true; return false; |
boolean | isTime(final Class type) Checks if is time. return Time.class.isAssignableFrom(type); |
boolean | isTime(final PropertyDescriptor pd) is Time return pd.getPropertyType().isAssignableFrom(java.sql.Time.class); |
boolean | isTime(String val) is Time try { if (null != java.sql.Time.valueOf(val)) return true; } catch (IllegalArgumentException iae) { return false; |
boolean | isTimeInRange(java.sql.Time start, java.sql.Time end, java.util.Date d) Tells you if the date part of a datetime is in a certain time range. d = new java.sql.Time(d.getHours(), d.getMinutes(), d.getSeconds()); if (start == null || end == null) { return false; if (start.before(end) && (!(d.after(start) && d.before(end)))) { return false; if (end.before(start) && (!(d.after(end) || d.before(start)))) { ... |
Timestamp | merge(java.util.Date date, java.util.Date time) merge Calendar d = Calendar.getInstance(); Calendar t = Calendar.getInstance(); d.setTimeInMillis(date.getTime()); t.setTimeInMillis(time.getTime()); d.set(Calendar.HOUR_OF_DAY, t.get(Calendar.HOUR_OF_DAY)); d.set(Calendar.MINUTE, t.get(Calendar.MINUTE)); d.set(Calendar.SECOND, t.get(Calendar.SECOND)); d.set(Calendar.MILLISECOND, t.get(Calendar.MILLISECOND)); ... |