Java Millisecond Current Get getMilliSecondToTomorrow(Date date)

Here you can find the source of getMilliSecondToTomorrow(Date date)

Description

get Milli Second To Tomorrow

License

Apache License

Declaration

public static long getMilliSecondToTomorrow(Date date) 

Method Source Code

//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;
    }
}

Related

  1. getCurrentTimeMillisStr()
  2. getMillins(String yyyyMMddHHmmss)
  3. getMillisDurationString(long millis)
  4. getMillisec_old(String isoDate)
  5. getMillisecondStamp(Date date)
  6. getMillisFromISO8601(Object iso8601)
  7. getMillisFromRFC822String(Object rfc822)
  8. getMillisFromString(String s)
  9. getMillisFromYYYYMMDD(Object yyyymmdd)