Java Timestamp delta_hours(Timestamp startdate, Timestamp enddate)

Here you can find the source of delta_hours(Timestamp startdate, Timestamp enddate)

Description

Returns the difference between two dates in hours

License

Open Source License

Declaration

public static Integer delta_hours(Timestamp startdate, Timestamp enddate) 

Method Source Code

//package com.java2s;
/**/*  w w w .  j  av a  2 s .c  o m*/
 * Exhibit A - UIRF Open-source Based Public Software License.
 * 
 * The contents of this file are subject to the UIRF Open-source Based Public
 * Software License(the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * openelis.uhl.uiowa.edu
 * 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * 
 * The Original Code is OpenELIS code.
 * 
 * The Initial Developer of the Original Code is The University of Iowa.
 * Portions created by The University of Iowa are Copyright 2006-2008. All
 * Rights Reserved.
 * 
 * Contributor(s): ______________________________________.
 * 
 * Alternatively, the contents of this file marked "Separately-Licensed" may be
 * used under the terms of a UIRF Software license ("UIRF Software License"), in
 * which case the provisions of a UIRF Software License are applicable instead
 * of those above.
 */

import java.sql.Timestamp;

public class Main {
    /**
     * Returns the difference between two dates in hours
     */
    public static Integer delta_hours(Timestamp startdate, Timestamp enddate) {
        Long span;
        if (startdate == null || enddate == null)
            return null;
        span = (enddate.getTime() - startdate.getTime()) / 1000 / 60 / 60;
        return span.intValue();
    }
}

Related

  1. datetime2ToTimestamp(long value, int fraction, int width)
  2. dateTimeToString(Timestamp dt, String df)
  3. dateToOracleStr(java.sql.Timestamp ts)
  4. dayNumber(Timestamp stamp)
  5. daysBetween(Timestamp t1, Timestamp t2)
  6. differDayByNow(Timestamp timestamp)
  7. doubleToTimestamp(double f)
  8. durationBetween(Timestamp startedAt, Timestamp completedAt)
  9. encodeTimestamp(Timestamp timestamp)