Here you can find the source of getDurationMinute(Timestamp createTime, Timestamp finishTime)
public static String getDurationMinute(Timestamp createTime, Timestamp finishTime)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; import java.sql.Timestamp; import java.text.DecimalFormat; public class Main { public static String getDurationMinute(Timestamp createTime, Timestamp finishTime) { String rtn = "0min"; if (createTime == null) { return rtn; }//from w w w . j a v a 2 s.c o m long ctime = createTime.getTime(); BigDecimal ct = new BigDecimal(Long.toString(ctime)); long ftime = System.currentTimeMillis(); if (finishTime != null) { ftime = finishTime.getTime(); } BigDecimal ft = new BigDecimal(Long.toString(ftime)); BigDecimal a = ft.subtract(ct); BigDecimal o = new BigDecimal("0"); if (a.compareTo(o) != 0) { BigDecimal thonsand = new BigDecimal("1000"); BigDecimal b = a.divide(thonsand, 2); BigDecimal sixty = new BigDecimal("60"); double du = b.divide(sixty, 2, BigDecimal.ROUND_HALF_UP).doubleValue(); DecimalFormat format = new DecimalFormat("###.##"); rtn = format.format(du) + "min"; } return rtn; } }