is Same Day Of Millisecond - Android java.util

Android examples for java.util:Day

Description

is Same Day Of Millisecond

Demo Code

import java.util.TimeZone;

public class Main {
  public static final int SECONDS_IN_DAY = 60 * 60 * 24;
  public static final long MILLIS_IN_DAY = 1000L * SECONDS_IN_DAY;

  private static long toDay(long millis) {
    return (millis + TimeZone.getDefault().getOffset(millis)) / MILLIS_IN_DAY;
  }/*from  w w w . j a v a2s  . co m*/

  public static boolean isSameDayOfMillis(final long ms1, final long ms2) {
    final long interval = ms1 - ms2;
    return interval < MILLIS_IN_DAY && interval > -1L * MILLIS_IN_DAY && toDay(ms1) == toDay(ms2);
  }

}

Related Tutorials