91 Format f = getFormat(); 92 93 if (f instanceof DateFormat) { 94 return ((DateFormat)f).getCalendar(); 95 } 96 return Calendar.getInstance(); 97 } 98 99 100 /** 101 * Returns true, as DateFormatterFilter will support 102 * incrementing/decrementing of the value. 103 */ 104 boolean getSupportsIncrement() { 105 return true; 106 } 107 108 /** 109 * Returns the field that will be adjusted by adjustValue. 110 */ 111 Object getAdjustField(int start, Map attributes) { 112 Iterator attrs = attributes.keySet().iterator(); 113 114 while (attrs.hasNext()) { 115 Object key = attrs.next(); 116 117 if ((key instanceof DateFormat.Field) && 118 (key == DateFormat.Field.HOUR1 || 119 ((DateFormat.Field)key).getCalendarField() != -1)) { 120 return key; 121 } 122 } 123 return null; 124 } 125 126 /** 127 * Adjusts the Date if FieldPosition identifies a known calendar 128 * field. 129 */ 130 Object adjustValue(Object value, Map attributes, Object key, 131 int direction) throws 132 BadLocationException, ParseException { 133 if (key != null) { 134 int field; 135 136 // HOUR1 has no corresponding calendar field, thus, map 137 // it to HOUR0 which will give the correct behavior. 138 if (key == DateFormat.Field.HOUR1) { 139 key = DateFormat.Field.HOUR0; 140 } 141 field = ((DateFormat.Field)key).getCalendarField(); 142 143 Calendar calendar = getCalendar(); 144 145 if (calendar != null) { 146 calendar.setTime((Date)value); 147 148 int fieldValue = calendar.get(field); 149 150 try { | 91 Format f = getFormat(); 92 93 if (f instanceof DateFormat) { 94 return ((DateFormat)f).getCalendar(); 95 } 96 return Calendar.getInstance(); 97 } 98 99 100 /** 101 * Returns true, as DateFormatterFilter will support 102 * incrementing/decrementing of the value. 103 */ 104 boolean getSupportsIncrement() { 105 return true; 106 } 107 108 /** 109 * Returns the field that will be adjusted by adjustValue. 110 */ 111 Object getAdjustField(int start, Map<?, ?> attributes) { 112 Iterator<?> attrs = attributes.keySet().iterator(); 113 114 while (attrs.hasNext()) { 115 Object key = attrs.next(); 116 117 if ((key instanceof DateFormat.Field) && 118 (key == DateFormat.Field.HOUR1 || 119 ((DateFormat.Field)key).getCalendarField() != -1)) { 120 return key; 121 } 122 } 123 return null; 124 } 125 126 /** 127 * Adjusts the Date if FieldPosition identifies a known calendar 128 * field. 129 */ 130 Object adjustValue(Object value, Map<?, ?> attributes, Object key, 131 int direction) throws 132 BadLocationException, ParseException { 133 if (key != null) { 134 int field; 135 136 // HOUR1 has no corresponding calendar field, thus, map 137 // it to HOUR0 which will give the correct behavior. 138 if (key == DateFormat.Field.HOUR1) { 139 key = DateFormat.Field.HOUR0; 140 } 141 field = ((DateFormat.Field)key).getCalendarField(); 142 143 Calendar calendar = getCalendar(); 144 145 if (calendar != null) { 146 calendar.setTime((Date)value); 147 148 int fieldValue = calendar.get(field); 149 150 try { |