Nicholas K already provided an answer nicely showing the use of java.time. I just wanted to add that java.time can do a bit more than shown there.
DateTimeFormatter factureLineFormatter
= DateTimeFormatter.ofPattern("'Facture du' dd/MM/uuuu");
String keyword = "Facture du";
String s = "Facture du 28/05/2018";
if (s.contains(keyword)) {
LocalDate date = LocalDate.parse(s, factureLineFormatter);
Month month = date.getMonth(); // Extract a `Month` enum object.
String output =
month.getDisplayName( // Get localized name of month.
TextStyle.FULL, // How long or abbreviated should the month name be.
Locale.FRENCH) // `Locale` determines the human language used in translation, and the cultural norms used in abbreviation, punctuation, and capitalization.
;
System.out.println(output);
}
Output:
mai
I am parsing the entire line immediately by adding the literal text in quotes in the format pattern string. I am printing the localized month name — here in French, but you can choose another language. You may also choose to have it abbreviated if you prefer.
Edit: Basil Bourque has kindly edited my code spelling out in comments what each method and argument does. This makes the code look long, but is great for the explanation in a Stack Overflow answer. In production code you would probably use a one-liner:
System.out.println(date.getMonth().getDisplayName(TextStyle.FULL, Locale.FRENCH));