22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.util;
27
28 import java.io.IOException;
29 import java.io.ObjectInputStream;
30 import java.util.GregorianCalendar;
31 import java.util.Locale;
32 import java.util.Map;
33 import java.util.TimeZone;
34 import sun.util.locale.provider.CalendarDataUtility;
35
36 public class BuddhistCalendar extends GregorianCalendar {
37
38 //////////////////
39 // Class Variables
40 //////////////////
41
42 private static final long serialVersionUID = -8527488697350388578L;
43
44 private static final int BUDDHIST_YEAR_OFFSET = 543;
45
46 ///////////////
47 // Constructors
48 ///////////////
49
50 /**
51 * Constructs a default BuddhistCalendar using the current time
52 * in the default time zone with the default locale.
53 */
54 public BuddhistCalendar() {
55 super();
56 }
57
58 /**
59 * Constructs a BuddhistCalendar based on the current time
60 * in the given time zone with the default locale.
61 * @param zone the given time zone.
237 final String yearField = "YEAR=";
238 int p = s.indexOf(yearField);
239 // If the string doesn't include the year value for some
240 // reason, then return the Gregorian string.
241 if (p == -1) {
242 return s;
243 }
244 p += yearField.length();
245 StringBuilder sb = new StringBuilder(s.length() + 10);
246 sb.append(s, 0, p);
247 // Skip the year number
248 while (Character.isDigit(s.charAt(p++)))
249 ;
250 int year = internalGet(YEAR) + BUDDHIST_YEAR_OFFSET;
251 sb.append(year).append(s, p - 1, s.length());
252 return sb.toString();
253 }
254
255 private transient int yearOffset = BUDDHIST_YEAR_OFFSET;
256
257 private void readObject(ObjectInputStream stream)
258 throws IOException, ClassNotFoundException {
259 stream.defaultReadObject();
260 yearOffset = BUDDHIST_YEAR_OFFSET;
261 }
262 }
|
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.util;
27
28 import java.io.IOException;
29 import java.io.ObjectInputStream;
30 import java.util.GregorianCalendar;
31 import java.util.Locale;
32 import java.util.Map;
33 import java.util.TimeZone;
34 import sun.util.locale.provider.CalendarDataUtility;
35
36 public class BuddhistCalendar extends GregorianCalendar {
37
38 //////////////////
39 // Class Variables
40 //////////////////
41
42 @java.io.Serial
43 private static final long serialVersionUID = -8527488697350388578L;
44
45 private static final int BUDDHIST_YEAR_OFFSET = 543;
46
47 ///////////////
48 // Constructors
49 ///////////////
50
51 /**
52 * Constructs a default BuddhistCalendar using the current time
53 * in the default time zone with the default locale.
54 */
55 public BuddhistCalendar() {
56 super();
57 }
58
59 /**
60 * Constructs a BuddhistCalendar based on the current time
61 * in the given time zone with the default locale.
62 * @param zone the given time zone.
238 final String yearField = "YEAR=";
239 int p = s.indexOf(yearField);
240 // If the string doesn't include the year value for some
241 // reason, then return the Gregorian string.
242 if (p == -1) {
243 return s;
244 }
245 p += yearField.length();
246 StringBuilder sb = new StringBuilder(s.length() + 10);
247 sb.append(s, 0, p);
248 // Skip the year number
249 while (Character.isDigit(s.charAt(p++)))
250 ;
251 int year = internalGet(YEAR) + BUDDHIST_YEAR_OFFSET;
252 sb.append(year).append(s, p - 1, s.length());
253 return sb.toString();
254 }
255
256 private transient int yearOffset = BUDDHIST_YEAR_OFFSET;
257
258 @java.io.Serial
259 private void readObject(ObjectInputStream stream)
260 throws IOException, ClassNotFoundException {
261 stream.defaultReadObject();
262 yearOffset = BUDDHIST_YEAR_OFFSET;
263 }
264 }
|