Java Date Format Check checkDateBetween(String time)

Here you can find the source of checkDateBetween(String time)

Description

check Date Between

License

Apache License

Declaration

public static Integer checkDateBetween(String time) throws Exception 

Method Source Code

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

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static Integer checkDateBetween(String time) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = sdf.parse(time);
        long diff = date.getTime() - new Date().getTime();
        long diffHours = diff / (60 * 60 * 1000);
        long diffMinutes = diff / (60 * 1000) % 60;
        int mins = (int) (diffHours * 60 + diffMinutes);
        return mins;
    }/*from   w  ww . jav  a2s  .c  om*/
}

Related

  1. checkDate(Date date)
  2. checkDate(String begingDate, String endDate)
  3. checkDate(String deadline)
  4. checkDateByMask(String sDateValue, String sDateFormat)
  5. checkDateFormat()
  6. checkDateFormat()
  7. checkDateFormat(String pattern)