1 /* |
1 /* |
2 * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
139 * Date formats are not synchronized. |
139 * Date formats are not synchronized. |
140 * It is recommended to create separate format instances for each thread. |
140 * It is recommended to create separate format instances for each thread. |
141 * If multiple threads access a format concurrently, it must be synchronized |
141 * If multiple threads access a format concurrently, it must be synchronized |
142 * externally. |
142 * externally. |
143 * |
143 * |
|
144 * @implSpec |
|
145 * <ul><li>The {@link #format(Date, StringBuffer, FieldPosition)} and |
|
146 * {@link #parse(String, ParsePosition)} methods may throw |
|
147 * {@code NullPointerException}, if any of their parameter is {@code null}. |
|
148 * The subclass may provide its own implementation and specification about |
|
149 * {@code NullPointerException}.</li> |
|
150 * <li>The {@link #setCalendar(Calendar)}, {@link |
|
151 * #setNumberFormat(NumberFormat)} and {@link #setTimeZone(TimeZone)} methods |
|
152 * do not throw {@code NullPointerException} when their parameter is |
|
153 * {@code null}, but any subsequent operations on the same instance may throw |
|
154 * {@code NullPointerException}.</li> |
|
155 * <li>The {@link #getCalendar()}, {@link #getNumberFormat()} and |
|
156 * {@link getTimeZone()} methods may return {@code null}, if the respective |
|
157 * values of this instance is set to {@code null} through the corresponding |
|
158 * setter methods. For Example: {@link #getTimeZone()} may return {@code null}, |
|
159 * if the {@code TimeZone} value of this instance is set as |
|
160 * {@link #setTimeZone(java.util.TimeZone) setTimeZone(null)}.</li> |
|
161 * </ul> |
|
162 * |
144 * @see Format |
163 * @see Format |
145 * @see NumberFormat |
164 * @see NumberFormat |
146 * @see SimpleDateFormat |
165 * @see SimpleDateFormat |
147 * @see java.util.Calendar |
166 * @see java.util.Calendar |
148 * @see java.util.GregorianCalendar |
167 * @see java.util.GregorianCalendar |
294 * the time string "1 PM PDT (Pacific Daylight Time)" using the pattern |
313 * the time string "1 PM PDT (Pacific Daylight Time)" using the pattern |
295 * "h a z (zzzz)" and the alignment field DateFormat.TIMEZONE_FIELD, |
314 * "h a z (zzzz)" and the alignment field DateFormat.TIMEZONE_FIELD, |
296 * the begin index and end index of fieldPosition will be set to |
315 * the begin index and end index of fieldPosition will be set to |
297 * 5 and 8, respectively, for the first occurrence of the timezone |
316 * 5 and 8, respectively, for the first occurrence of the timezone |
298 * pattern character 'z'. |
317 * pattern character 'z'. |
|
318 * @exception IllegalArgumentException if the {@code Format} cannot format |
|
319 * the given {@code obj}. |
299 * @see java.text.Format |
320 * @see java.text.Format |
300 */ |
321 */ |
301 public final StringBuffer format(Object obj, StringBuffer toAppendTo, |
322 public final StringBuffer format(Object obj, StringBuffer toAppendTo, |
302 FieldPosition fieldPosition) |
323 FieldPosition fieldPosition) |
303 { |
324 { |