Here you can find the source of getMilliSecondToTomorrow(Date date)
public static long getMilliSecondToTomorrow(Date date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private final static ThreadLocal<SimpleDateFormat> YYYY_MM_DD_FORMAT = new ThreadLocal<SimpleDateFormat>() { @Override/* w w w .ja va 2 s. c om*/ protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd"); } ; }; public static long getMilliSecondToTomorrow(Date date) { String today = formatDD(date); Date today0 = parseDD(today); return (86400000 - (date.getTime() - today0.getTime())); } /** * yyyy-MM-dd * * @param date * @return */ public static String formatDD(Date date) { return YYYY_MM_DD_FORMAT.get().format(date); } /** * yyyy-MM-dd * * @param dateStr * @return * @throws ParseException */ public static Date parseDD(String dateStr) { try { return YYYY_MM_DD_FORMAT.get().parse(dateStr); } catch (Exception e) { } return null; } }