use of java.text.DateFormatSymbols in project j2objc by google.
the class DateFormatTest method test_getTimeInstance.
/**
* @tests java.text.DateFormat#getTimeInstance()
*/
public void test_getTimeInstance() {
SimpleDateFormat f2 = (SimpleDateFormat) DateFormat.getTimeInstance();
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertTrue("Wrong default", f2.equals(DateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.getDefault())));
assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(new DateFormatSymbols()));
assertTrue("Doesn't work", f2.format(new Date()).getClass() == String.class);
}
use of java.text.DateFormatSymbols in project j2objc by google.
the class SimpleDateFormatTest method test_Constructor.
public void test_Constructor() {
// Test for method java.text.SimpleDateFormat()
SimpleDateFormat f2 = new SimpleDateFormat();
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertTrue("Wrong default", f2.equals(DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, Locale.getDefault())));
assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(new DateFormatSymbols()));
assertTrue("Doesn't work", f2.format(new Date()).getClass() == String.class);
}
use of java.text.DateFormatSymbols in project j2objc by google.
the class SimpleDateFormatTest method test_hashCode.
public void test_hashCode() {
SimpleDateFormat format = (SimpleDateFormat) DateFormat.getInstance();
SimpleDateFormat clone = (SimpleDateFormat) format.clone();
assertTrue("clone has not equal hash code", clone.hashCode() == format.hashCode());
format.format(new Date());
assertTrue("clone has not equal hash code after format", clone.hashCode() == format.hashCode());
DateFormatSymbols symbols = new DateFormatSymbols(Locale.ENGLISH);
symbols.setEras(new String[] { "Before", "After" });
SimpleDateFormat format2 = new SimpleDateFormat("y'y'yy", symbols);
assertFalse("objects has equal hash code", format2.hashCode() == format.hashCode());
}
use of java.text.DateFormatSymbols in project j2objc by google.
the class SimpleDateFormatTest method test_ConstructorLjava_lang_String.
public void test_ConstructorLjava_lang_String() {
// Test for method java.text.SimpleDateFormat(java.lang.String)
SimpleDateFormat f2 = new SimpleDateFormat("yyyy");
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertEquals("Wrong pattern", "yyyy", f2.toPattern());
assertTrue("Wrong locale", f2.equals(new SimpleDateFormat("yyyy", Locale.getDefault())));
assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(new DateFormatSymbols()));
assertTrue("Doesn't work", f2.format(new Date()).getClass() == String.class);
// Invalid constructor value.
try {
new SimpleDateFormat("this is an invalid simple date format");
fail("Expected test_ConstructorLjava_lang_String to throw IAE.");
} catch (IllegalArgumentException ex) {
// expected
}
// Null string value
try {
new SimpleDateFormat(null);
fail("Expected test_ConstructorLjava_lang_String to throw NPE.");
} catch (NullPointerException ex) {
// expected
}
}
use of java.text.DateFormatSymbols in project j2objc by google.
the class SimpleDateFormatTest method test_setDateFormatSymbolsLjava_text_DateFormatSymbols.
public void test_setDateFormatSymbolsLjava_text_DateFormatSymbols() {
// Test for method void
// java.text.SimpleDateFormat.setDateFormatSymbols(java.text.DateFormatSymbols)
SimpleDateFormat f1 = new SimpleDateFormat("a");
DateFormatSymbols symbols = new DateFormatSymbols();
symbols.setAmPmStrings(new String[] { "morning", "night" });
f1.setDateFormatSymbols(symbols);
DateFormatSymbols newSym = f1.getDateFormatSymbols();
assertTrue("Set incorrectly", newSym.equals(symbols));
assertTrue("Not a clone", f1.getDateFormatSymbols() != symbols);
String result = f1.format(new GregorianCalendar(1999, Calendar.JUNE, 12, 3, 0).getTime());
assertEquals("Incorrect symbols used", "morning", result);
symbols.setEras(new String[] { "before", "after" });
assertTrue("Identical symbols", !f1.getDateFormatSymbols().equals(symbols));
try {
f1.setDateFormatSymbols(null);
fail();
} catch (NullPointerException expected) {
}
}
Aggregations