--- old/src/java.base/share/classes/java/text/SimpleDateFormat.java 2019-01-17 08:32:08.700762496 -0800 +++ new/src/java.base/share/classes/java/text/SimpleDateFormat.java 2019-01-17 08:32:07.317733573 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -533,6 +533,8 @@ 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"; @@ -1189,7 +1191,7 @@ } break; - case PATTERN_MONTH: // 'M' (context seinsive) + case PATTERN_MONTH: // 'M' (context sensitive) if (useDateFormatSymbols) { String[] months; if (count >= 4) { @@ -1203,7 +1205,7 @@ if (count < 3) { current = null; } else if (forceStandaloneForm) { - current = calendar.getDisplayName(field, style | 0x8000, locale); + current = calendar.getDisplayName(field, style | STANDALONE_MASK, locale); if (current == null) { current = calendar.getDisplayName(field, style, locale); } @@ -1227,7 +1229,7 @@ } } else { if (count >= 3) { - current = calendar.getDisplayName(field, style | 0x8000, locale); + current = calendar.getDisplayName(field, style | STANDALONE_MASK, locale); } } if (current == null) { @@ -2033,7 +2035,7 @@ return index; } } else { - Map map = getDisplayNamesMap(field, locale); + Map map = getDisplayContextNamesMap(field, locale); if ((index = matchString(text, start, field, map, calb)) > 0) { return index; } @@ -2449,6 +2451,19 @@ return map; } + // for 'M' pattern only + private Map getDisplayContextNamesMap(int field, Locale locale) { + Map map = calendar.getDisplayNames(field, + Calendar.SHORT_FORMAT | (forceStandaloneForm ? STANDALONE_MASK : 0), locale); + // Get LONG styles + Map 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.