|
1 | 1 | /* |
2 | | - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
@@ -364,33 +364,35 @@ int parseYear(String year, int defaultYear) { |
364 | 364 | } |
365 | 365 |
|
366 | 366 | Month parseMonth(String mon) { |
367 | | - switch (mon) { |
368 | | - case "Jan": return Month.JANUARY; |
369 | | - case "Feb": return Month.FEBRUARY; |
370 | | - case "Mar": return Month.MARCH; |
371 | | - case "Apr": return Month.APRIL; |
372 | | - case "May": return Month.MAY; |
373 | | - case "Jun": return Month.JUNE; |
374 | | - case "Jul": return Month.JULY; |
375 | | - case "Aug": return Month.AUGUST; |
376 | | - case "Sep": return Month.SEPTEMBER; |
377 | | - case "Oct": return Month.OCTOBER; |
378 | | - case "Nov": return Month.NOVEMBER; |
379 | | - case "Dec": return Month.DECEMBER; |
380 | | - } |
| 367 | + int len = mon.length(); |
| 368 | + |
| 369 | + if (mon.regionMatches(true, 0, "January", 0, len)) return Month.JANUARY; |
| 370 | + if (mon.regionMatches(true, 0, "February", 0, len)) return Month.FEBRUARY; |
| 371 | + if (mon.regionMatches(true, 0, "March", 0, len)) return Month.MARCH; |
| 372 | + if (mon.regionMatches(true, 0, "April", 0, len)) return Month.APRIL; |
| 373 | + if (mon.regionMatches(true, 0, "May", 0, len)) return Month.MAY; |
| 374 | + if (mon.regionMatches(true, 0, "June", 0, len)) return Month.JUNE; |
| 375 | + if (mon.regionMatches(true, 0, "July", 0, len)) return Month.JULY; |
| 376 | + if (mon.regionMatches(true, 0, "August", 0, len)) return Month.AUGUST; |
| 377 | + if (mon.regionMatches(true, 0, "September", 0, len)) return Month.SEPTEMBER; |
| 378 | + if (mon.regionMatches(true, 0, "October", 0, len)) return Month.OCTOBER; |
| 379 | + if (mon.regionMatches(true, 0, "November", 0, len)) return Month.NOVEMBER; |
| 380 | + if (mon.regionMatches(true, 0, "December", 0, len)) return Month.DECEMBER; |
| 381 | + |
381 | 382 | throw new IllegalArgumentException("Unknown month: " + mon); |
382 | 383 | } |
383 | 384 |
|
384 | 385 | DayOfWeek parseDayOfWeek(String dow) { |
385 | | - switch (dow) { |
386 | | - case "Mon": return DayOfWeek.MONDAY; |
387 | | - case "Tue": return DayOfWeek.TUESDAY; |
388 | | - case "Wed": return DayOfWeek.WEDNESDAY; |
389 | | - case "Thu": return DayOfWeek.THURSDAY; |
390 | | - case "Fri": return DayOfWeek.FRIDAY; |
391 | | - case "Sat": return DayOfWeek.SATURDAY; |
392 | | - case "Sun": return DayOfWeek.SUNDAY; |
393 | | - } |
| 386 | + int len = dow.length(); |
| 387 | + |
| 388 | + if (dow.regionMatches(true, 0, "Monday", 0, len)) return DayOfWeek.MONDAY; |
| 389 | + if (dow.regionMatches(true, 0, "Tuesday", 0, len)) return DayOfWeek.TUESDAY; |
| 390 | + if (dow.regionMatches(true, 0, "Wednesday", 0, len)) return DayOfWeek.WEDNESDAY; |
| 391 | + if (dow.regionMatches(true, 0, "Thursday", 0, len)) return DayOfWeek.THURSDAY; |
| 392 | + if (dow.regionMatches(true, 0, "Friday", 0, len)) return DayOfWeek.FRIDAY; |
| 393 | + if (dow.regionMatches(true, 0, "Saturday", 0, len)) return DayOfWeek.SATURDAY; |
| 394 | + if (dow.regionMatches(true, 0, "Sunday", 0, len)) return DayOfWeek.SUNDAY; |
| 395 | + |
394 | 396 | throw new IllegalArgumentException("Unknown day-of-week: " + dow); |
395 | 397 | } |
396 | 398 |
|
|
0 commit comments