Here you can find the source of getTimeSubFromNowTime(String time)
public static long getTimeSubFromNowTime(String time)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long getTimeSubFromNowTime(String time) { int year = Integer.parseInt(getLocationCurrentDate().split("-")[0]); int month = Integer.parseInt(getLocationCurrentDate().split("-")[1]); int day = Integer.parseInt(getLocationCurrentDate().split("-")[2]); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try {// w ww . j a v a 2 s .c om Date date = format.parse(year + "-" + month + "-" + day + " " + time); Date now = new Date(); return date.getTime() - now.getTime(); } catch (ParseException e) { return 0; } } public static String getLocationCurrentDate() { return new SimpleDateFormat("yyyy-MM-dd").format(new Date()); } }