fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.stream.*;
  5. import java.lang.*;
  6. import java.io.*;
  7. import java.time.format.*;
  8. import java.time.*;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13.  
  14. static LocalDateTime dateTime = LocalDateTime.now();
  15.  
  16. static Stream<String> repeatedRuns(String c, int start, int end) {
  17. return IntStream
  18. .rangeClosed(start, end)
  19. .mapToObj(len ->
  20. Collections.nCopies(len, c).stream().collect(Collectors.joining(""))
  21. );
  22. }
  23.  
  24. static void printDateTime(String pattern) {
  25. DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);
  26. System.out.println(pattern + ", " + dtf.format(dateTime));
  27. }
  28.  
  29. public static void main(String[] args) {
  30. Stream<String> patterns = repeatedRuns("E", 1, 4)
  31. .flatMap(e -> repeatedRuns("M", 1, 4).map(m -> e + " " + m))
  32. .map(em -> em + " d");
  33.  
  34. patterns.forEach(Ideone::printDateTime);
  35. }
  36.  
  37. }
Success #stdin #stdout 0.18s 4386816KB
stdin
Standard input is empty
stdout
E M d, Sat 7 1
E MM d, Sat 07 1
E MMM d, Sat Jul 1
E MMMM d, Sat July 1
EE M d, Sat 7 1
EE MM d, Sat 07 1
EE MMM d, Sat Jul 1
EE MMMM d, Sat July 1
EEE M d, Sat 7 1
EEE MM d, Sat 07 1
EEE MMM d, Sat Jul 1
EEE MMMM d, Sat July 1
EEEE M d, Saturday 7 1
EEEE MM d, Saturday 07 1
EEEE MMM d, Saturday Jul 1
EEEE MMMM d, Saturday July 1