Java Date Difference dateDiffer(String time1, String time2, String formatStr)

Here you can find the source of dateDiffer(String time1, String time2, String formatStr)

Description

date Differ

License

Open Source License

Declaration

public static long dateDiffer(String time1, String time2, String formatStr) throws ParseException 

Method Source Code

//package com.java2s;
/**//from www .j  a va  2 s  . c om
 * Project: szs-demo
 * 
 * File Created at 2016?8?19?
 * chiukong
 * 
 * Copyright 2015 Dafy Finance Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Dafy Finance Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with http://www.dafy.com.
 */

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

import java.util.Date;

public class Main {

    public static long dateDiffer(String time1, String time2, String formatStr) throws ParseException {
        SimpleDateFormat sp = new SimpleDateFormat(formatStr);
        Date date1 = sp.parse(time1);
        Date date2 = sp.parse(time2);
        long differ = Math.abs(date1.getTime() - date2.getTime());
        return differ;
    }
}

Related

  1. dateDiff(int interval, Date begin, Date end)
  2. dateDiff(java.util.Date a, java.util.Date b)
  3. dateDiff(String startDate, String endDate)
  4. dateDiff(String startTime, String endTime, String format)
  5. DateDiff(String strDateBegin, String strDateEnd, int iType)
  6. dateDiffInDays(Date dateStart, Date dateEnd)
  7. dateDiffInDaysIgnoreTime(Date dateStart, Date dateEnd)
  8. dateDiffMonth(Date d1, Date d2)
  9. dateDiffWithNow(Calendar sDate)