Java Code Examples for java.text.DateFormat#MONTH_FIELD

The following examples show how to use java.text.DateFormat#MONTH_FIELD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldPositionTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
/**
 * @tests java.text.FieldPosition#FieldPosition(java.text.Format$Field, int)
 */
public void test_ConstructorLjava_text_Format$FieldI() {
	// Test for constructor java.text.FieldPosition(Format.Field, int)
	FieldPosition fpos = new FieldPosition(DateFormat.Field.MONTH,
			DateFormat.MONTH_FIELD);
	assertSame("Constructor failed to set field attribute!",
			DateFormat.Field.MONTH, fpos.getFieldAttribute());
	assertEquals("Test1: Constructor failed to set field identifier!",
			DateFormat.MONTH_FIELD, fpos.getField());

	// test special cases
	FieldPosition fpos2 = new FieldPosition(DateFormat.Field.HOUR1,
			DateFormat.HOUR1_FIELD);
	assertSame("Constructor failed to set field attribute!",
			DateFormat.Field.HOUR1, fpos2.getFieldAttribute());
	assertEquals("Test2: Constructor failed to set field identifier!",
			DateFormat.HOUR1_FIELD, fpos2.getField());

	FieldPosition fpos3 = new FieldPosition(DateFormat.Field.TIME_ZONE,
			DateFormat.MONTH_FIELD);
	assertSame("Constructor failed to set field attribute!",
			DateFormat.Field.TIME_ZONE, fpos3.getFieldAttribute());
	assertEquals("Test3: Constructor failed to set field identifier!",
			DateFormat.MONTH_FIELD, fpos3.getField());
}
 
Example 2
Source File: FieldPositionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * @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());
}