Advertisement
DulcetAirman

find month

Apr 15th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. package ch.fhnw.claudemartin;
  2.  
  3. import java.time.Month;
  4. import java.time.format.TextStyle;
  5. import java.util.EnumSet;
  6. import java.util.Locale;
  7.  
  8. public class SomeClass {
  9.  
  10.   public static void main(final String[] args) {
  11.     final EnumSet<Month> months = EnumSet.allOf(Month.class);
  12.     final String input = "Oktober";// That's German
  13.     final Locale locale = Locale.FRENCH;
  14.     final boolean anyMatch = months.stream()
  15.         .map(m -> m.getDisplayName(TextStyle.FULL, locale))
  16.         .anyMatch(m -> m.equals(input));
  17.     if (!anyMatch) {
  18.       System.err.println("not found");
  19.     }
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement