use of java.util.TimeZone in project robolectric by robolectric.
the class Strftime method format.
/**
* Format a date string.
*
* @param format The format in strftime syntax.
* @param date The date to format.
* @param locale The locale to use for formatting.
* @param zone The timezone to use for formatting.
* @return The formatted datetime.
*/
public static String format(String format, final Date date, Locale locale, TimeZone zone) {
StringBuffer buffer = new StringBuffer();
class Formatter {
SimpleDateFormat formatter;
public Formatter(Date date, Locale locale, TimeZone timeZone) {
if (locale != null) {
formatter = new SimpleDateFormat("", locale);
} else {
formatter = new SimpleDateFormat("");
}
if (timeZone != null) {
formatter.setTimeZone(timeZone);
}
}
public String format(String format) {
formatter.applyPattern(format);
return formatter.format(date);
}
}
Formatter formatter = new Formatter(date, locale, zone);
Boolean inside = false;
Boolean removePad = false;
Boolean zeroPad = false;
Boolean spacePad = false;
Boolean upperCase = false;
Boolean swapCase = false;
StringBuffer padWidthBuffer = new StringBuffer();
for (int i = 0; i < format.length(); i++) {
Character c = format.charAt(i);
if (!inside && c == '%') {
inside = true;
removePad = false;
zeroPad = false;
spacePad = false;
upperCase = false;
swapCase = false;
padWidthBuffer = new StringBuffer();
} else if (inside) {
inside = false;
switch(c) {
// %a Abbreviated weekday name according to locale.
case 'a':
buffer.append(correctCase(formatter.format("EEE"), upperCase, swapCase));
break;
// %A Full weekday name according to locale.
case 'A':
buffer.append(correctCase(formatter.format("EEEE"), upperCase, swapCase));
break;
// %b Abbreviated month name according to locale.
case 'b':
buffer.append(correctCase(formatter.format("MMM"), upperCase, swapCase));
break;
// %B Full month name according to locale.
case 'B':
buffer.append(correctCase(formatter.format("MMMM"), upperCase, swapCase));
break;
// %c Preferred date and time representation for locale.
case 'c':
// NOTE: en_US locale
buffer.append(formatter.format("EEE dd MMM yyyy hh:mm:ss aa z"));
break;
// %C Year divided by 100 and truncated to integer (00-99).
case 'C':
buffer.append(formatter.format("y").substring(0, 2));
break;
// %d Day of the month as decimal number (01-31).
case 'd':
buffer.append(formatter.format("dd"));
break;
// %D Same as "%m/%d/%y"
case 'D':
buffer.append(formatter.format("MM/dd/yy"));
break;
// %e Day of the month as decimal number, padded with space.
case 'e':
buffer.append(correctPad(formatter.format("dd"), zeroPad, true, removePad, (padWidthBuffer.length() <= 0 ? new StringBuffer("2") : padWidthBuffer)));
break;
// %E Modifier, use a locale-dependent alternative representation.
case 'E':
inside = true;
throw new UnsupportedOperationException("Not implemented yet");
// %F ISO 8601 date format: "%Y-%m-%d".
case 'F':
buffer.append(formatter.format("yyyy-MM-dd"));
break;
// %g 2-digit year version of %G, (00-99)
case 'g':
buffer.append(formatter.format("YY"));
break;
// %G ISO 8601 week-based year.
case 'G':
buffer.append(formatter.format("YYYY"));
break;
// %h Like %b.
case 'h':
buffer.append(formatter.format("MMM"));
break;
// %H Hour (24-hour clock) as decimal number (00-23).
case 'H':
buffer.append(formatter.format("HH"));
break;
// %I Hour (12-hour clock) as decimal number (01-12).
case 'I':
buffer.append(formatter.format("hh"));
break;
// %j Day of the year as decimal number (001-366).
case 'j':
buffer.append(formatter.format("DDD"));
break;
// %k Hour (24-hour clock) as decimal number (0-23), space padded.
case 'k':
buffer.append(correctPad(formatter.format("HH"), zeroPad, spacePad, removePad, (padWidthBuffer.length() <= 0 ? new StringBuffer("2") : padWidthBuffer)));
break;
// %l Hour (12-hour clock) as decimal number (1-12), space padded.
case 'l':
buffer.append(correctPad(formatter.format("hh"), zeroPad, spacePad || !zeroPad, removePad, (padWidthBuffer.length() <= 0 ? new StringBuffer("2") : padWidthBuffer)));
break;
// %m Month as decimal number (01-12).
case 'm':
buffer.append(correctPad(formatter.format("MM"), zeroPad, spacePad, removePad, (padWidthBuffer.length() <= 0 ? new StringBuffer("2") : padWidthBuffer)));
break;
// %M Minute as decimal number (00-59).
case 'M':
buffer.append(correctCase(formatter.format("mm"), upperCase, swapCase));
break;
// %n Newline.
case 'n':
buffer.append(formatter.format("\n"));
break;
// %O Modifier, use alternative numeric symbols (say, Roman numerals).
case 'O':
inside = true;
throw new UnsupportedOperationException("Not implemented yet");
// %p "AM", "PM", or locale string. Noon = "PM", midnight = "AM".
case 'p':
buffer.append(correctCase(formatter.format("a"), upperCase, swapCase));
break;
// %P "am", "pm", or locale string. Noon = "pm", midnight = "am".
case 'P':
buffer.append(correctCase(formatter.format("a").toLowerCase(), upperCase, swapCase));
break;
// %r 12-hour clock time.
case 'r':
buffer.append(formatter.format("hh:mm:ss a"));
break;
// %R 24-hour clock time, "%H:%M".
case 'R':
buffer.append(formatter.format("HH:mm"));
break;
// %s Number of seconds since Epoch, 1970-01-01 00:00:00 +0000 (UTC).
case 's':
buffer.append(((Long) (date.getTime() / 1000)).toString());
break;
// %S Second as decimal number (00-60). 60 for leap seconds.
case 'S':
buffer.append(formatter.format("ss"));
break;
// %t Tab.
case 't':
buffer.append(formatter.format("\t"));
break;
// %T 24-hour time, "%H:%M:%S".
case 'T':
buffer.append(formatter.format("HH:mm:ss"));
break;
// %u The day of the week as a decimal, (1-7). Monday being 1.
case 'u':
buffer.append(formatter.format("u"));
break;
// Starting with the first Sunday as the first day of week 01.
case 'U':
throw new UnsupportedOperationException("Not implemented yet");
// Week 1 is the first week that has at least 4 days in the new year.
case 'V':
buffer.append(formatter.format("ww"));
break;
// %w Day of the week as a decimal, (0-6). Sunday being 0.
case 'w':
// (1-7)
String dayNumberOfWeek = formatter.format("u");
buffer.append((dayNumberOfWeek.equals("7") ? "0" : dayNumberOfWeek));
break;
// Starting with the first Monday as the first day of week 01.
case 'W':
throw new UnsupportedOperationException("Not implemented yet");
// %x Locale date without time.
case 'x':
buffer.append(formatter.format("MM/dd/yyyy"));
break;
// %X Locale time without date.
case 'X':
buffer.append(formatter.format("hh:mm:ss aa"));
// formatter.format("HH:mm:ss"));
break;
// %y Year as decimal number without century (00-99).
case 'y':
buffer.append(formatter.format("yy"));
break;
// %Y Year as decimal number with century.
case 'Y':
buffer.append(formatter.format("yyyy"));
break;
// %z Numeric timezone as hour and minute offset from UTC "+hhmm" or "-hhmm".
case 'z':
buffer.append(formatter.format("Z"));
break;
// %Z Timezone, name, or abbreviation.
case 'Z':
buffer.append(formatter.format("z"));
break;
// %% Literal '%'.
case '%':
buffer.append(formatter.format("%"));
break;
// %^ Force upper case.
case '^':
inside = true;
upperCase = true;
break;
// %# Swap case.
case '#':
inside = true;
swapCase = true;
break;
// %- Remove padding.
case '-':
inside = true;
removePad = true;
break;
// %_ Space pad.
case '_':
inside = true;
spacePad = true;
break;
// 0 Alternatively if preceded by another digit, defines padding width.
case '0':
inside = true;
if (padWidthBuffer.length() == 0) {
zeroPad = true;
spacePad = false;
} else {
padWidthBuffer.append(c);
}
break;
// %1 Padding width.
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
inside = true;
// zeroPad = !spacePad; // Default to zero padding.
padWidthBuffer.append(c);
break;
default:
buffer.append(c.toString());
break;
}
} else {
buffer.append(c.toString());
}
}
return buffer.toString();
}
use of java.util.TimeZone in project robovm by robovm.
the class DateIntervalFormatTest method test10089890.
// http://b/10089890 - we should take the given time zone into account.
public void test10089890() throws Exception {
Locale l = Locale.US;
TimeZone utc = TimeZone.getTimeZone("UTC");
TimeZone pacific = TimeZone.getTimeZone("America/Los_Angeles");
int flags = FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL | FORMAT_SHOW_TIME | FORMAT_24HOUR;
// The Unix epoch is UTC, so 0 is 1970-01-01T00:00Z...
assertEquals("Jan 1, 1970, 00:00 – Jan 2, 1970, 00:00", formatDateRange(l, utc, 0, DAY + 1, flags));
// But MTV is hours behind, so 0 was still the afternoon of the previous day...
assertEquals("Dec 31, 1969, 16:00 – Jan 1, 1970, 16:00", formatDateRange(l, pacific, 0, DAY, flags));
}
use of java.util.TimeZone in project robovm by robovm.
the class DateIntervalFormatTest method test10560853_for_single_day_events.
// http://b/10560853 - when the start and end times are otherwise on the same day,
// an end time 0 ms into the next day is considered to belong to the previous day.
public void test10560853_for_single_day_events() throws Exception {
Locale l = Locale.US;
TimeZone utc = TimeZone.getTimeZone("UTC");
int flags = FORMAT_SHOW_TIME | FORMAT_24HOUR | FORMAT_SHOW_DATE;
assertEquals("January 1, 1970, 22:00–00:00", formatDateRange(l, utc, 22 * HOUR, 24 * HOUR, flags));
assertEquals("January 1, 1970, 22:00 – January 2, 1970, 00:30", formatDateRange(l, utc, 22 * HOUR, 24 * HOUR + 30 * MINUTE, flags));
}
use of java.util.TimeZone in project robovm by robovm.
the class DateIntervalFormatTest method test10209343_when_this_year.
// http://b/10209343 - for the current year, we should honor the FORMAT_SHOW_YEAR flags.
public void test10209343_when_this_year() {
// Construct a date in the current year (whenever the test happens to be run).
Locale l = Locale.US;
TimeZone utc = TimeZone.getTimeZone("UTC");
Calendar c = Calendar.getInstance(utc, l);
c.set(Calendar.MONTH, Calendar.FEBRUARY);
c.set(Calendar.DAY_OF_MONTH, 10);
c.set(Calendar.HOUR_OF_DAY, 0);
long thisYear = c.getTimeInMillis();
// You don't get the year if it's this year...
assertEquals("February 10", formatDateRange(l, utc, thisYear, thisYear, FORMAT_SHOW_DATE));
// ...unless you explicitly ask for it.
assertEquals(String.format("February 10, %d", c.get(Calendar.YEAR)), formatDateRange(l, utc, thisYear, thisYear, FORMAT_SHOW_DATE | FORMAT_SHOW_YEAR));
// ...or it's not actually this year...
Calendar c2 = (Calendar) c.clone();
c2.set(Calendar.YEAR, 1980);
long oldYear = c2.getTimeInMillis();
assertEquals("February 10, 1980", formatDateRange(l, utc, oldYear, oldYear, FORMAT_SHOW_DATE));
// (But you can disable that!)
assertEquals("February 10", formatDateRange(l, utc, oldYear, oldYear, FORMAT_SHOW_DATE | FORMAT_NO_YEAR));
// ...or the start and end years aren't the same...
assertEquals(String.format("February 10, 1980 – February 10, %d", c.get(Calendar.YEAR)), formatDateRange(l, utc, oldYear, thisYear, FORMAT_SHOW_DATE));
// (And you can't avoid that --- icu4c steps in and overrides you.)
assertEquals(String.format("February 10, 1980 – February 10, %d", c.get(Calendar.YEAR)), formatDateRange(l, utc, oldYear, thisYear, FORMAT_SHOW_DATE | FORMAT_NO_YEAR));
}
use of java.util.TimeZone in project robovm by robovm.
the class DateIntervalFormatTest method test_formatDateInterval.
// These are the old CTS tests for DateIntervalFormat.formatDateRange.
public void test_formatDateInterval() throws Exception {
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
Calendar c = Calendar.getInstance(tz, Locale.US);
c.set(Calendar.MONTH, Calendar.JANUARY);
c.set(Calendar.DAY_OF_MONTH, 19);
c.set(Calendar.HOUR_OF_DAY, 3);
c.set(Calendar.MINUTE, 30);
c.set(Calendar.SECOND, 15);
long timeWithCurrentYear = c.getTimeInMillis();
c.set(Calendar.YEAR, 2009);
long fixedTime = c.getTimeInMillis();
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
long onTheHour = c.getTimeInMillis();
long noonDuration = (8 * 60 + 30) * 60 * 1000 - 15 * 1000;
long midnightDuration = (3 * 60 + 30) * 60 * 1000 + 15 * 1000;
Locale de_DE = new Locale("de", "DE");
Locale en_US = new Locale("en", "US");
Locale es_ES = new Locale("es", "ES");
Locale es_US = new Locale("es", "US");
assertEquals("Monday", formatDateRange(en_US, tz, fixedTime, fixedTime + HOUR, FORMAT_SHOW_WEEKDAY));
assertEquals("January 19", formatDateRange(en_US, tz, timeWithCurrentYear, timeWithCurrentYear + HOUR, FORMAT_SHOW_DATE));
assertEquals("3:30 AM", formatDateRange(en_US, tz, fixedTime, fixedTime, FORMAT_SHOW_TIME));
assertEquals("January 19, 2009", formatDateRange(en_US, tz, fixedTime, fixedTime + HOUR, FORMAT_SHOW_YEAR));
assertEquals("January 19", formatDateRange(en_US, tz, fixedTime, fixedTime + HOUR, FORMAT_NO_YEAR));
assertEquals("January", formatDateRange(en_US, tz, timeWithCurrentYear, timeWithCurrentYear + HOUR, FORMAT_NO_MONTH_DAY));
assertEquals("3:30 AM", formatDateRange(en_US, tz, fixedTime, fixedTime, FORMAT_12HOUR | FORMAT_SHOW_TIME));
assertEquals("03:30", formatDateRange(en_US, tz, fixedTime, fixedTime, FORMAT_24HOUR | FORMAT_SHOW_TIME));
assertEquals("3:30 AM", formatDateRange(en_US, tz, fixedTime, fixedTime, FORMAT_12HOUR | /*| FORMAT_CAP_AMPM*/
FORMAT_SHOW_TIME));
assertEquals("12:00 PM", formatDateRange(en_US, tz, fixedTime + noonDuration, fixedTime + noonDuration, FORMAT_12HOUR | FORMAT_SHOW_TIME));
assertEquals("12:00 PM", formatDateRange(en_US, tz, fixedTime + noonDuration, fixedTime + noonDuration, FORMAT_12HOUR | FORMAT_SHOW_TIME));
assertEquals("12:00 PM", formatDateRange(en_US, tz, fixedTime + noonDuration, fixedTime + noonDuration, FORMAT_12HOUR | /*| FORMAT_NO_NOON*/
FORMAT_SHOW_TIME));
assertEquals("12:00 AM", formatDateRange(en_US, tz, fixedTime - midnightDuration, fixedTime - midnightDuration, FORMAT_12HOUR | FORMAT_SHOW_TIME));
assertEquals("3:30 AM", formatDateRange(en_US, tz, fixedTime, fixedTime, FORMAT_SHOW_TIME | FORMAT_UTC));
assertEquals("3 AM", formatDateRange(en_US, tz, onTheHour, onTheHour, FORMAT_SHOW_TIME | FORMAT_ABBREV_TIME));
assertEquals("Mon", formatDateRange(en_US, tz, fixedTime, fixedTime + HOUR, FORMAT_SHOW_WEEKDAY | FORMAT_ABBREV_WEEKDAY));
assertEquals("Jan 19", formatDateRange(en_US, tz, timeWithCurrentYear, timeWithCurrentYear + HOUR, FORMAT_SHOW_DATE | FORMAT_ABBREV_MONTH));
assertEquals("Jan 19", formatDateRange(en_US, tz, timeWithCurrentYear, timeWithCurrentYear + HOUR, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("1/19/2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * HOUR, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("1/19/2009 – 1/22/2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("1/19/2009 – 4/22/2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("1/19/2009 – 2/9/2012", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19.1.2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + HOUR, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19.01.2009 - 22.01.2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19.01.2009 - 22.04.2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19.01.2009 - 09.02.2012", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("1/19/2009", formatDateRange(es_US, tz, fixedTime, fixedTime + HOUR, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19/1/2009 – 22/1/2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19/1/2009 – 22/4/2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19/1/2009 – 9/2/2012", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19/1/2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + HOUR, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19/1/2009 – 22/1/2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19/1/2009 – 22/4/2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
assertEquals("19/1/2009 – 9/2/2012", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_YEAR | FORMAT_NUMERIC_DATE));
// These are some random other test cases I came up with.
assertEquals("January 19–22, 2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * DAY, 0));
assertEquals("Jan 19–22, 2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("Mon, Jan 19 – Thu, Jan 22, 2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_WEEKDAY | FORMAT_ABBREV_ALL));
assertEquals("Monday, January 19 – Thursday, January 22, 2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_WEEKDAY));
assertEquals("January 19 – April 22, 2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * MONTH, 0));
assertEquals("Jan 19 – Apr 22, 2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("Mon, Jan 19 – Wed, Apr 22, 2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_WEEKDAY | FORMAT_ABBREV_ALL));
assertEquals("January–April 2009", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_NO_MONTH_DAY));
assertEquals("Jan 19, 2009 – Feb 9, 2012", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("Jan 2009 – Feb 2012", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_NO_MONTH_DAY | FORMAT_ABBREV_ALL));
assertEquals("January 19, 2009 – February 9, 2012", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * YEAR, 0));
assertEquals("Monday, January 19, 2009 – Thursday, February 9, 2012", formatDateRange(en_US, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_WEEKDAY));
// The same tests but for de_DE.
assertEquals("19.-22. Januar 2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * DAY, 0));
assertEquals("19.-22. Jan. 2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("Mo., 19. - Do., 22. Jan. 2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_WEEKDAY | FORMAT_ABBREV_ALL));
assertEquals("Montag, 19. - Donnerstag, 22. Januar 2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_WEEKDAY));
assertEquals("19. Januar - 22. April 2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * MONTH, 0));
assertEquals("19. Jan. - 22. Apr. 2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("Mo., 19. Jan. - Mi., 22. Apr. 2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_WEEKDAY | FORMAT_ABBREV_ALL));
assertEquals("Januar-April 2009", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_NO_MONTH_DAY));
assertEquals("19. Jan. 2009 - 9. Feb. 2012", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("Jan. 2009 - Feb. 2012", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_NO_MONTH_DAY | FORMAT_ABBREV_ALL));
assertEquals("19. Januar 2009 - 9. Februar 2012", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * YEAR, 0));
assertEquals("Montag, 19. Januar 2009 - Donnerstag, 9. Februar 2012", formatDateRange(de_DE, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_WEEKDAY));
// The same tests but for es_US.
assertEquals("19–22 enero 2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * DAY, 0));
assertEquals("19–22 ene 2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("lun 19 ene – jue 22 ene 2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_WEEKDAY | FORMAT_ABBREV_ALL));
assertEquals("lunes 19 enero – jueves 22 enero 2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_WEEKDAY));
assertEquals("19 enero – 22 abril 2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * MONTH, 0));
assertEquals("19 ene – 22 abr 2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("lun 19 ene – mié 22 abr 2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_WEEKDAY | FORMAT_ABBREV_ALL));
assertEquals("enero–abril 2009", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_NO_MONTH_DAY));
assertEquals("19 ene 2009 – 9 feb 2012", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("ene 2009 – feb 2012", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_NO_MONTH_DAY | FORMAT_ABBREV_ALL));
assertEquals("19 enero 2009 – 9 febrero 2012", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * YEAR, 0));
assertEquals("lunes 19 enero 2009 – jueves 9 febrero 2012", formatDateRange(es_US, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_WEEKDAY));
// The same tests but for es_ES.
assertEquals("19–22 enero 2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * DAY, 0));
assertEquals("19–22 ene 2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("lun 19 ene – jue 22 ene 2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_WEEKDAY | FORMAT_ABBREV_ALL));
assertEquals("lunes 19 enero – jueves 22 enero 2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * DAY, FORMAT_SHOW_WEEKDAY));
assertEquals("19 enero – 22 abril 2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * MONTH, 0));
assertEquals("19 ene – 22 abr 2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("lun 19 ene – mié 22 abr 2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_SHOW_WEEKDAY | FORMAT_ABBREV_ALL));
assertEquals("enero–abril 2009", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * MONTH, FORMAT_NO_MONTH_DAY));
assertEquals("19 ene 2009 – 9 feb 2012", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_DATE | FORMAT_ABBREV_ALL));
assertEquals("ene 2009 – feb 2012", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_NO_MONTH_DAY | FORMAT_ABBREV_ALL));
assertEquals("19 enero 2009 – 9 febrero 2012", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * YEAR, 0));
assertEquals("lunes 19 enero 2009 – jueves 9 febrero 2012", formatDateRange(es_ES, tz, fixedTime, fixedTime + 3 * YEAR, FORMAT_SHOW_WEEKDAY));
}
Aggregations