Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Date;

public class Main {

    public static float getHourDiff(long date1, long date2) {
        return (float) ((date2 - date1) / 3600000.0);
    }

    public static float getHourDiff(Date date1, Date date2) {
        return getHourDiff(date1.getTime(), date2.getTime());
    }

    public static float getHourDiff(Date date) {
        return getHourDiff(date, new Date());
    }

    public static float getHourDiff(long date) {
        return getHourDiff(date, new Date().getTime());
    }
}