Search in sources :

Example 16 with FieldPosition

use of java.text.FieldPosition in project j2objc by google.

the class DecimalFormatTest method test_setGroupingUsed.

public void test_setGroupingUsed() {
    DecimalFormat format = new DecimalFormat();
    StringBuffer buf = new StringBuffer();
    format.setGroupingUsed(false);
    format.format(new Long(1970), buf, new FieldPosition(0));
    assertEquals("1970", buf.toString());
    assertFalse(format.isGroupingUsed());
    format.format(new Long(1970), buf, new FieldPosition(0));
    assertEquals("19701970", buf.toString());
    assertFalse(format.isGroupingUsed());
    format.setGroupingUsed(true);
    format.format(new Long(1970), buf, new FieldPosition(0));
    assertEquals("197019701,970", buf.toString());
    assertTrue(format.isGroupingUsed());
}
Also used : DecimalFormat(java.text.DecimalFormat) FieldPosition(java.text.FieldPosition)

Example 17 with FieldPosition

use of java.text.FieldPosition in project j2objc by google.

the class MessageFormatTest method test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition.

public void test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition() {
    new Support_MessageFormat("test_formatLjava_lang_ObjectLjava_lang_StringBufferLjava_text_FieldPosition").t_format_with_FieldPosition();
    String pattern = "On {4,date} at {3,time}, he ate {2,number, integer} hamburger{2,choice,1#|1<s}.";
    MessageFormat format = new MessageFormat(pattern, Locale.US);
    Object[] objects = new Object[] { "", new Integer(3), 8, "" };
    try {
        format.format(objects, new StringBuffer(), new FieldPosition(DateFormat.Field.AM_PM));
        fail();
    } catch (IllegalArgumentException expected) {
    }
}
Also used : MessageFormat(java.text.MessageFormat) FieldPosition(java.text.FieldPosition)

Example 18 with FieldPosition

use of java.text.FieldPosition in project j2objc by google.

the class FieldPositionTest method test_ConstructorLjava_text_Format$Field.

/**
	 * @tests java.text.FieldPosition#FieldPosition(java.text.Format$Field)
	 */
public void test_ConstructorLjava_text_Format$Field() {
    // Test for constructor java.text.FieldPosition(Format.Field)
    FieldPosition fpos = new FieldPosition(DateFormat.Field.MONTH);
    assertSame("Constructor failed to set field attribute!", DateFormat.Field.MONTH, fpos.getFieldAttribute());
    assertEquals("Test1: Constructor failed to set field identifier!", -1, fpos.getField());
}
Also used : FieldPosition(java.text.FieldPosition)

Example 19 with FieldPosition

use of java.text.FieldPosition in project j2objc by google.

the class FieldPositionTest method test_ConstructorI.

/**
	 * @tests java.text.FieldPosition#FieldPosition(int)
	 */
public void test_ConstructorI() {
    // Test for constructor java.text.FieldPosition(int)
    FieldPosition fpos = new FieldPosition(DateFormat.MONTH_FIELD);
    assertEquals("Test1: Constructor failed to set field identifier!", DateFormat.MONTH_FIELD, fpos.getField());
    assertNull("Constructor failed to set field attribute!", fpos.getFieldAttribute());
}
Also used : FieldPosition(java.text.FieldPosition)

Example 20 with FieldPosition

use of java.text.FieldPosition in project j2objc by google.

the class FieldPositionTest method test_toString.

/**
	 * @tests java.text.FieldPosition#toString()
	 */
public void test_toString() {
    // Test for method java.lang.String java.text.FieldPosition.toString()
    FieldPosition fpos = new FieldPosition(1);
    fpos.setBeginIndex(2);
    fpos.setEndIndex(3);
    assertEquals("ToString returned the wrong value:", "java.text.FieldPosition[field=1,attribute=null,beginIndex=2,endIndex=3]", fpos.toString());
    FieldPosition fpos2 = new FieldPosition(DateFormat.Field.ERA);
    fpos2.setBeginIndex(4);
    fpos2.setEndIndex(5);
    assertEquals("ToString returned the wrong value:", "java.text.FieldPosition[field=-1,attribute=" + DateFormat.Field.ERA + ",beginIndex=4,endIndex=5]", fpos2.toString());
}
Also used : FieldPosition(java.text.FieldPosition)

Aggregations

FieldPosition (java.text.FieldPosition)60 Date (java.util.Date)18 SimpleDateFormat (java.text.SimpleDateFormat)15 IsoDateFormat (alma.acs.util.IsoDateFormat)9 DecimalFormat (java.text.DecimalFormat)9 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)8 ACSLogParser (alma.acs.logging.engine.parser.ACSLogParser)5 MessageFormat (java.text.MessageFormat)5 DateFormat (java.text.DateFormat)4 NumberFormat (java.text.NumberFormat)3 ParsePosition (java.text.ParsePosition)3 Vector (java.util.Vector)3 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)2 ChoiceFormat (java.text.ChoiceFormat)2 ParseException (java.text.ParseException)2 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 List (java.util.List)2 Random (java.util.Random)2 EObject (org.eclipse.emf.ecore.EObject)2