Search in sources :

Example 61 with DateFormatSymbols

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);
}
Also used : DateFormatSymbols(java.text.DateFormatSymbols) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 62 with DateFormatSymbols

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);
}
Also used : DateFormatSymbols(java.text.DateFormatSymbols) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 63 with DateFormatSymbols

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());
}
Also used : DateFormatSymbols(java.text.DateFormatSymbols) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 64 with DateFormatSymbols

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
    }
}
Also used : DateFormatSymbols(java.text.DateFormatSymbols) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 65 with DateFormatSymbols

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) {
    }
}
Also used : GregorianCalendar(java.util.GregorianCalendar) DateFormatSymbols(java.text.DateFormatSymbols) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

DateFormatSymbols (java.text.DateFormatSymbols)90 SimpleDateFormat (java.text.SimpleDateFormat)30 Date (java.util.Date)23 Locale (java.util.Locale)15 Resources (android.content.res.Resources)12 ArrayList (java.util.ArrayList)11 View (android.view.View)9 TextView (android.widget.TextView)8 OnClickListener (android.view.View.OnClickListener)6 Calendar (java.util.Calendar)6 GregorianCalendar (java.util.GregorianCalendar)6 RelativeLayout (android.widget.RelativeLayout)5 Test (org.junit.Test)5 LayoutParams (android.app.ActionBar.LayoutParams)4 Typeface (android.graphics.Typeface)4 List (java.util.List)4 TypedArray (android.content.res.TypedArray)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectInputStream (java.io.ObjectInputStream)3