SHARE
TWEET

find month

DulcetAirman Apr 15th, 2016 (edited) 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top