Java SQL Time equalsTime(Time time1, Time time2)

Here you can find the source of equalsTime(Time time1, Time time2)

Description

equals Time

License

LGPL

Declaration

public static boolean equalsTime(Time time1, Time time2) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.sql.Time;

import java.util.Calendar;

public class Main {
    public static boolean equalsTime(Time time1, Time time2) {
        boolean result = false;
        if (time1 != null && time2 != null) {
            Calendar calendar = Calendar.getInstance();

            calendar.setTime(time1);//from   w w  w  .  j a va 2 s  .  c  o m
            calendar.set(Calendar.DAY_OF_MONTH, 1);
            calendar.set(Calendar.MONTH, 0);
            calendar.set(Calendar.YEAR, 1970);
            calendar.set(Calendar.MILLISECOND, 0);
            java.util.Date date1 = calendar.getTime();

            calendar.setTime(time2);
            calendar.set(Calendar.DAY_OF_MONTH, 1);
            calendar.set(Calendar.MONTH, 0);
            calendar.set(Calendar.YEAR, 1970);
            calendar.set(Calendar.MILLISECOND, 0);
            java.util.Date date2 = calendar.getTime();

            long v1 = date1.getTime();
            long v2 = date2.getTime();
            result = (v1 == v2);
        } else if (time1 == null && time2 == null) {
            result = true;
        }
        return result;
    }
}

Related

  1. DateTimeSpace(String starttime, String endtime)
  2. dateTimeToStr(java.util.Date date)
  3. daytime()
  4. deserializeSqlTime(String text)
  5. double2Time(Number zahl)
  6. extractTime(Date date)
  7. getCalTime(Time startTime, Calendar cal)
  8. getClassForSqlType(String sqlType, Class dateTimeClass)
  9. getClosestIDByTime(Connection con, String table, long time)