| 196 | * @since 3.35/4.30 |
| 197 | */ |
| 198 | public static Meridiem parse( |
| 199 | CharSequence text, |
| 200 | Locale locale, |
| 201 | TextWidth width, |
| 202 | OutputContext context |
| 203 | ) throws ParseException { |
| 204 | |
| 205 | if (text.length() == 2) { |
| 206 | char c2 = text.charAt(1); |
| 207 | if (c2 == 'M' || c2 == 'm') { |
| 208 | char c1 = text.charAt(0); |
| 209 | if (c1 == 'A' || c1 == 'a') { |
| 210 | return Meridiem.AM; |
| 211 | } else if (c1 == 'P' || c1 == 'p') { |
| 212 | return Meridiem.PM; |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | ParsePosition pp = new ParsePosition(0); |
| 218 | Meridiem m = CalendarText.getIsoInstance(locale).getMeridiems(width, context).parse(text, pp, Meridiem.class); |
| 219 | |
| 220 | if (m == null) { |
| 221 | throw new ParseException("Cannot parse: " + text, pp.getErrorIndex()); |
| 222 | } else { |
| 223 | return m; |
| 224 | } |
| 225 | |
| 226 | } |
| 227 | |
| 228 | @Override |
| 229 | public boolean test(WallTime context) { |