fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.time.* ;
  8. import java.time.format.* ;
  9. import java.util.stream.* ;
  10. import java.time.temporal.TemporalAdjusters ;
  11.  
  12. /* Name of the class has to be "Main" only if the class is public. */
  13. class Ideone
  14. {
  15. public static void main (String[] args) throws java.lang.Exception
  16. {
  17. System.out.println( Ideone.germanDaysOfWeek );
  18.  
  19. String input = "Montag";
  20.  
  21. LocalDate today = LocalDate.now();
  22. LocalDate nextWeekday = today.with(
  23. TemporalAdjusters.next(germanDaysOfWeek.get(input)));
  24.  
  25. System.out.println( nextWeekday ) ;
  26. }
  27.  
  28. private static final Map<String, DayOfWeek> germanDaysOfWeek =
  29. .stream( DayOfWeek.values() )
  30. .collect(
  31. Collectors.toMap(
  32. d -> d.getDisplayName(TextStyle.FULL, Locale.GERMAN),
  33. d -> d
  34. )
  35. );
  36. }
Success #stdin #stdout 0.17s 52972KB
stdin
Standard input is empty
stdout
{Freitag=FRIDAY, Samstag=SATURDAY, Montag=MONDAY, Mittwoch=WEDNESDAY, Donnerstag=THURSDAY, Dienstag=TUESDAY, Sonntag=SUNDAY}
2022-05-16