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

DategetZeroTimeDate(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());
...
BooleanisBetweenHours(Time hora, Time horaInicio, Time horaFim)
is Between Hours
return (hora.equals(horaInicio) || (hora.after(horaInicio) && hora.before(horaFim))
        || hora.equals(horaFim));
booleanisCategoryDateOrTime(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;
...
booleanisDateTime(int type)
is Date Time
if (type == Types.DATE) {
    return true;
} else {
    return false;
booleanisDateTime(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;
booleanisTime(final Class type)
Checks if is time.
return Time.class.isAssignableFrom(type);
booleanisTime(final PropertyDescriptor pd)
is Time
return pd.getPropertyType().isAssignableFrom(java.sql.Time.class);
booleanisTime(String val)
is Time
try {
    if (null != java.sql.Time.valueOf(val))
        return true;
} catch (IllegalArgumentException iae) {
return false;
booleanisTimeInRange(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)))) {
...
Timestampmerge(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));
...