Java Date Compare sameTimeInOneMinute(Date date1, Date date2)

Here you can find the source of sameTimeInOneMinute(Date date1, Date date2)

Description

same Time In One Minute

License

Apache License

Declaration

public static boolean sameTimeInOneMinute(Date date1, Date date2) 

Method Source Code


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

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static boolean sameTimeInOneMinute(Date date1, Date date2) {
        return Math.abs(getMinuteCa(date1, date2)) <= 1;
    }/*from  w  ww .j av a  2 s . co m*/

    public static long getMinuteCa(Date d1, Date d2) {
        long quot = Math.abs(d1.getTime() - d2.getTime());
        quot = quot / 1000 / 60;
        return quot;
    }

    public static long getTime(String s) {
        return parseMysql(s).getTime();
    }

    public static Date parseMysql(String s) {
        try {
            DateFormat fmtTemp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            return fmtTemp.parse(s);
        } catch (ParseException e) {
            return null;
        }
    }
}

Related

  1. max(final Date a, final Date b)
  2. max(Set dateSet)
  3. mergeNonDateKeys(List rowKeys, List columnKeys)
  4. min(Calendar... dates)
  5. min(Date datum1, Date datum2)