public static String formatDateRange(Locale locale, TimeZone tz, long startMs, long endMs, int flags) { Calendar startCalendar = Calendar.getInstance(tz); startCalendar.setTimeInMillis(startMs); Calendar endCalendar; if (startMs == endMs) { endCalendar = startCalendar; } else { endCalendar = Calendar.getInstance(tz); endCalendar.setTimeInMillis(endMs); } boolean endsAtMidnight = isMidnight(endCalendar); // If we're not showing the time or the start and end times are on the same day, and the // end time is midnight, fudge the end date so we don't count the day that's about to start. // This is not the behavior of icu4c's DateIntervalFormat, but it's the historical behavior // of Android's DateUtils.formatDateRange. if (startMs != endMs && endsAtMidnight && ((flags & FORMAT_SHOW_TIME) == 0 || julianDay(startCalendar) == julianDay(endCalendar))) { endCalendar.roll(Calendar.DAY_OF_MONTH, false); endMs -= DAY_IN_MS; } String skeleton = toSkeleton(startCalendar, endCalendar, flags); synchronized (CACHED_FORMATTERS) { return formatDateInterval(getFormatter(skeleton, locale.toString(), tz.getID()), startMs, endMs); } }
public static String formatDateRange(Locale locale, TimeZone tz, long startMs, long endMs, int flags) { Calendar startCalendar = Calendar.getInstance(tz); startCalendar.setTimeInMillis(startMs); Calendar endCalendar; if (startMs == endMs) { endCalendar = startCalendar; } else { endCalendar = Calendar.getInstance(tz); endCalendar.setTimeInMillis(endMs); } boolean endsAtMidnight = isMidnight(endCalendar); // If we're not showing the time or the start and end times are on the same day, and the // end time is midnight, fudge the end date so we don't count the day that's about to start. // This is not the behavior of icu4c's DateIntervalFormat, but it's the historical behavior // of Android's DateUtils.formatDateRange. if (startMs != endMs && endsAtMidnight && ((flags & FORMAT_SHOW_TIME) == 0 || julianDay(startCalendar) == julianDay(endCalendar))) { endCalendar.roll(Calendar.DAY_OF_MONTH, false); endMs -= DAY_IN_MS; } String skeleton = toSkeleton(startCalendar, endCalendar, flags); synchronized (CACHED_FORMATTERS) { return formatDateInterval(getFormatter(skeleton, locale.toString(), tz.getID()), startMs, endMs); } }
public static String formatDateRange(Locale locale, TimeZone tz, long startMs, long endMs, int flags) { Calendar startCalendar = Calendar.getInstance(tz); startCalendar.setTimeInMillis(startMs); Calendar endCalendar; if (startMs == endMs) { endCalendar = startCalendar; } else { endCalendar = Calendar.getInstance(tz); endCalendar.setTimeInMillis(endMs); } boolean endsAtMidnight = isMidnight(endCalendar); // If we're not showing the time or the start and end times are on the same day, and the // end time is midnight, fudge the end date so we don't count the day that's about to start. // This is not the behavior of icu4c's DateIntervalFormat, but it's the historical behavior // of Android's DateUtils.formatDateRange. if (startMs != endMs && endsAtMidnight && ((flags & FORMAT_SHOW_TIME) == 0 || julianDay(startCalendar) == julianDay(endCalendar))) { endCalendar.roll(Calendar.DAY_OF_MONTH, false); endMs -= DAY_IN_MS; } String skeleton = toSkeleton(startCalendar, endCalendar, flags); synchronized (CACHED_FORMATTERS) { return formatDateInterval(getFormatter(skeleton, locale.toString(), tz.getID()), startMs, endMs); } }
public static String formatDateRange(Locale locale, TimeZone tz, long startMs, long endMs, int flags) { Calendar startCalendar = Calendar.getInstance(tz); startCalendar.setTimeInMillis(startMs); Calendar endCalendar; if (startMs == endMs) { endCalendar = startCalendar; } else { endCalendar = Calendar.getInstance(tz); endCalendar.setTimeInMillis(endMs); } boolean endsAtMidnight = isMidnight(endCalendar); // If we're not showing the time or the start and end times are on the same day, and the // end time is midnight, fudge the end date so we don't count the day that's about to start. // This is not the behavior of icu4c's DateIntervalFormat, but it's the historical behavior // of Android's DateUtils.formatDateRange. if (startMs != endMs && endsAtMidnight && ((flags & FORMAT_SHOW_TIME) == 0 || julianDay(startCalendar) == julianDay(endCalendar))) { endCalendar.roll(Calendar.DAY_OF_MONTH, false); endMs -= DAY_IN_MS; } String skeleton = toSkeleton(startCalendar, endCalendar, flags); synchronized (CACHED_FORMATTERS) { return formatDateInterval(getFormatter(skeleton, locale.toString(), tz.getID()), startMs, endMs); } }
public static String formatDateRange(Locale locale, TimeZone tz, long startMs, long endMs, int flags) { Calendar startCalendar = Calendar.getInstance(tz); startCalendar.setTimeInMillis(startMs); Calendar endCalendar; if (startMs == endMs) { endCalendar = startCalendar; } else { endCalendar = Calendar.getInstance(tz); endCalendar.setTimeInMillis(endMs); } boolean endsAtMidnight = isMidnight(endCalendar); // If we're not showing the time or the start and end times are on the same day, and the // end time is midnight, fudge the end date so we don't count the day that's about to start. // This is not the behavior of icu4c's DateIntervalFormat, but it's the historical behavior // of Android's DateUtils.formatDateRange. if (startMs != endMs && endsAtMidnight && ((flags & FORMAT_SHOW_TIME) == 0 || julianDay(startCalendar) == julianDay(endCalendar))) { endCalendar.roll(Calendar.DAY_OF_MONTH, false); endMs -= DAY_IN_MS; } String skeleton = toSkeleton(startCalendar, endCalendar, flags); synchronized (CACHED_FORMATTERS) { return formatDateInterval(getFormatter(skeleton, locale.toString(), tz.getID()), startMs, endMs); } }
public static String formatDateRange(Locale locale, TimeZone tz, long startMs, long endMs, int flags) { Calendar startCalendar = Calendar.getInstance(tz); startCalendar.setTimeInMillis(startMs); Calendar endCalendar; if (startMs == endMs) { endCalendar = startCalendar; } else { endCalendar = Calendar.getInstance(tz); endCalendar.setTimeInMillis(endMs); } boolean endsAtMidnight = isMidnight(endCalendar); // If we're not showing the time or the start and end times are on the same day, and the // end time is midnight, fudge the end date so we don't count the day that's about to start. // This is not the behavior of icu4c's DateIntervalFormat, but it's the historical behavior // of Android's DateUtils.formatDateRange. if (startMs != endMs && endsAtMidnight && ((flags & FORMAT_SHOW_TIME) == 0 || julianDay(startCalendar) == julianDay(endCalendar))) { endCalendar.roll(Calendar.DAY_OF_MONTH, false); endMs -= DAY_IN_MS; } String skeleton = toSkeleton(startCalendar, endCalendar, flags); synchronized (CACHED_FORMATTERS) { return formatDateInterval(getFormatter(skeleton, locale.toString(), tz.getID()), startMs, endMs); } }
public static String formatDateRange(Locale locale, TimeZone tz, long startMs, long endMs, int flags) { Calendar startCalendar = Calendar.getInstance(tz); startCalendar.setTimeInMillis(startMs); Calendar endCalendar; if (startMs == endMs) { endCalendar = startCalendar; } else { endCalendar = Calendar.getInstance(tz); endCalendar.setTimeInMillis(endMs); } boolean endsAtMidnight = isMidnight(endCalendar); // If we're not showing the time or the start and end times are on the same day, and the // end time is midnight, fudge the end date so we don't count the day that's about to start. // This is not the behavior of icu4c's DateIntervalFormat, but it's the historical behavior // of Android's DateUtils.formatDateRange. if (startMs != endMs && endsAtMidnight && ((flags & FORMAT_SHOW_TIME) == 0 || julianDay(startCalendar) == julianDay(endCalendar))) { endCalendar.roll(Calendar.DAY_OF_MONTH, false); endMs -= DAY_IN_MS; } String skeleton = toSkeleton(startCalendar, endCalendar, flags); synchronized (CACHED_FORMATTERS) { return formatDateInterval(getFormatter(skeleton, locale.toString(), tz.getID()), startMs, endMs); } }