Java SQL Time Create substract(Time thisDeparture, Time firstDeparture)

Here you can find the source of substract(Time thisDeparture, Time firstDeparture)

Description

substract

License

Open Source License

Declaration

public static Time substract(Time thisDeparture, Time firstDeparture) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Time;
import java.util.Calendar;
import java.util.TimeZone;

public class Main {
    public static Time substract(Time thisDeparture, Time firstDeparture) {
        Calendar firstCal = Calendar.getInstance(TimeZone.getDefault());
        firstCal.setTime(firstDeparture);
        Calendar secondCal = Calendar.getInstance(TimeZone.getDefault());
        secondCal.setTime(thisDeparture);
        secondCal.add(Calendar.HOUR_OF_DAY, 0 - firstCal.get(Calendar.HOUR_OF_DAY));
        secondCal.add(Calendar.MINUTE, 0 - firstCal.get(Calendar.MINUTE));
        secondCal.add(Calendar.SECOND, 0 - firstCal.get(Calendar.SECOND));
        return new Time(secondCal.getTime().getTime());
    }/*from w w w .j a  v a2 s  . c  o  m*/
}

Related

  1. getTomorrowOrderTime()
  2. getUserToServerDateTime(TimeZone timeZone, int dateFormat, int timeFormat, String date, Locale locale)
  3. getWaitTimeout(Connection con)
  4. getYear(String dateTime)
  5. getYear(String dateTime)
  6. SumTime(Time t1, Time t2)
  7. sumTimes(String[] timeStrings, DateFormat df)
  8. time2Double(java.sql.Time time)
  9. time2String(final java.sql.Time value)