Parsing into YearMonth

I would like to parse two separate strings "1982" and "SEP" into a java.time.YearMonth object.

java.time.YearMonth.parse("1978 SEP", java.time.format.DateTimeFormatter.ofPattern("yyyy LLL"))

gives me

java.time.format.DateTimeParseException: Text '1978 SEP' could not be parsed at index 5
  at java.time.format.DateTimeFormatter.parseResolved0(
  at java.time.format.DateTimeFormatter.parse(
  at java.time.YearMonth.parse(

There are 3 (possibly 2) problems here:

  • Your locale isn't English, so "SEP" can't be understood as September. This can be fixed by setting the English locale to the formatter.
  • DateTimeFormatter is case sensitive by default so you need to build a case insensitive formatter.
  • You shouldn't use the "L" token but "M" instead: refer to this question.

The following will work:

DateTimeFormatter formatter = new DateTimeFormatterBuilder()
                                    .appendPattern("yyyy MMM")
System.out.println(YearMonth.parse("1978 SEP", formatter));

I compiled my program and I got the following error. How should I resolve it? Note: uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.

We are developing a Java application to be run on Linux environments (Ubuntu for now) which communicates with a piece of hardware. Said hardware uses a .so library made available by the manufacturer ...

I have some terrible beaviour. I have the following Maven configuration: <project xmlns="" xmlns:xsi="" xsi:...

Latest project I used java8 , found it's very convenient to process Collection type, it gave me great surprise. But suddenly feel some conventional syntax are so cumbersome, for example I have an ...