< prev index next >

src/java.base/share/classes/java/text/SimpleDateFormat.java

Print this page
rev 53363 : [mq]: 8216969

*** 1,7 **** /* ! * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 531,540 **** --- 531,542 ---- private transient int defaultCenturyStartYear; private static final int MILLIS_PER_MINUTE = 60 * 1000; + private static final int STANDALONE_MASK = 0x8000; // Calendar.STANDALONE_MASK + // For time zones that have no names, use strings GMT+minutes and // GMT-minutes. For instance, in France the time zone is GMT+60. private static final String GMT = "GMT"; /**
*** 1187,1197 **** maxIntCount, buffer); } } break; ! case PATTERN_MONTH: // 'M' (context seinsive) if (useDateFormatSymbols) { String[] months; if (count >= 4) { months = formatData.getMonths(); current = months[value]; --- 1189,1199 ---- maxIntCount, buffer); } } break; ! case PATTERN_MONTH: // 'M' (context sensitive) if (useDateFormatSymbols) { String[] months; if (count >= 4) { months = formatData.getMonths(); current = months[value];
*** 1201,1211 **** } } else { if (count < 3) { current = null; } else if (forceStandaloneForm) { ! current = calendar.getDisplayName(field, style | 0x8000, locale); if (current == null) { current = calendar.getDisplayName(field, style, locale); } } } --- 1203,1213 ---- } } else { if (count < 3) { current = null; } else if (forceStandaloneForm) { ! current = calendar.getDisplayName(field, style | STANDALONE_MASK, locale); if (current == null) { current = calendar.getDisplayName(field, style, locale); } } }
*** 1225,1235 **** months = formatData.getShortMonths(); current = months[value]; } } else { if (count >= 3) { ! current = calendar.getDisplayName(field, style | 0x8000, locale); } } if (current == null) { zeroPaddingNumber(value+1, count, maxIntCount, buffer); } --- 1227,1237 ---- months = formatData.getShortMonths(); current = months[value]; } } else { if (count >= 3) { ! current = calendar.getDisplayName(field, style | STANDALONE_MASK, locale); } } if (current == null) { zeroPaddingNumber(value+1, count, maxIntCount, buffer); }
*** 2031,2041 **** if ((index = matchString(text, start, Calendar.MONTH, formatData.getShortMonths(), calb)) > 0) { return index; } } else { ! Map<String, Integer> map = getDisplayNamesMap(field, locale); if ((index = matchString(text, start, field, map, calb)) > 0) { return index; } } break parsing; --- 2033,2043 ---- if ((index = matchString(text, start, Calendar.MONTH, formatData.getShortMonths(), calb)) > 0) { return index; } } else { ! Map<String, Integer> map = getDisplayContextNamesMap(field, locale); if ((index = matchString(text, start, field, map, calb)) > 0) { return index; } } break parsing;
*** 2447,2456 **** --- 2449,2471 ---- } } return map; } + // for 'M' pattern only + private Map<String, Integer> getDisplayContextNamesMap(int field, Locale locale) { + Map<String, Integer> map = calendar.getDisplayNames(field, + Calendar.SHORT_FORMAT | (forceStandaloneForm ? STANDALONE_MASK : 0), locale); + // Get LONG styles + Map<String, Integer> m = calendar.getDisplayNames(field, + Calendar.LONG_FORMAT | (forceStandaloneForm ? STANDALONE_MASK : 0), locale); + if (m != null) { + map.putAll(m); + } + return map; + } + /** * After reading an object from the input stream, the format * pattern in the object is verified. * * @exception InvalidObjectException if the pattern is invalid
< prev index next >