Java TimeZone Add toMidnight(long time, TimeZone tz)

Here you can find the source of toMidnight(long time, TimeZone tz)

Description

to Midnight

License

Apache License

Declaration

public static final long toMidnight(long time, TimeZone tz) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.TimeZone;

public class Main {
    private static final long MILLIS_IN_DAY = 86400000l;

    public static final long toMidnight(long time, TimeZone tz) {
        return toMidnight(time, 0, tz);
    }//from   www .java 2  s  .  c  o m

    public static final long toMidnight(long time, int nDays, TimeZone tz) {
        Calendar c = Calendar.getInstance(tz);
        c.setTimeInMillis(time + nDays * MILLIS_IN_DAY);
        c.set(Calendar.HOUR_OF_DAY, 23);
        c.set(Calendar.MINUTE, 59);
        c.set(Calendar.SECOND, 59);
        c.set(Calendar.MILLISECOND, 999);
        return c.getTimeInMillis();
    }
}

Related

  1. nowWithTimeZone(TimeZone timezone)
  2. removeTimeZoneOffset(long t)
  3. shiftDate(Date date, TimeZone timeZone, String pattern)
  4. stringToCal(String s, TimeZone tz)
  5. stringToCalendar(String strDate, TimeZone timezone)
  6. tomorrow(TimeZone zone)