先把它们格式化为Date格式。然后调用getTime方法获得long型的毫秒值。两者相减。
再转为分钟

解决方案 »

  1.   

    /**
     * 按两个日期型字符串,计算两个日期相隔的天数
     * @param firstString
     * @param secondString
     * @return int 天数
     */
    public int nDaysBetweenTwoDate(String firstString, String secondString) {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    Date firstDate = null;
    Date secondDate = null;
    try {
    firstDate = df.parse(firstString);
    secondDate = df.parse(secondString);
    } catch (Exception e) {
    // 日期型字符串格式错误
    } int nDay =
    (int) ((secondDate.getTime() - firstDate.getTime())
    / (24 * 60 * 60 * 1000));
    return nDay;
    }
      

  2.   

    /**
     * 按两个日期,计算两个日期相隔的天数
     * @param firstDate
     * @param secondDate
     * @return int 天数
     */
    public int nDaysBetweenTwoDate(Date firstDate, Date secondDate) {
    int nDay =
    (int) ((secondDate.getTime() - firstDate.getTime())
    / (24 * 60 * 60 * 1000));
    return nDay;
    }
      

  3.   

    用System.currentTimeMillis()得到开始和终了时间,
    他们的差就是你要的了!