[JAVA] Made a one-liner method for Premium Friday

Readability is the worst Please forgive that January will come in 2017.


import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
import java.time.YearMonth;
import java.util.Arrays;
import java.util.stream.IntStream;

public class PremiumFriday {
    public static void main(String[] args) {
        String year = "2017";
        Arrays.stream(Month.values()).map(m ->IntStream.range(1,YearMonth.of(Integer.parseInt(year), m).atEndOfMonth().lengthOfMonth()+1).mapToObj(d -> LocalDate.of(Integer.parseInt(year), m, d)).filter(d -> DayOfWeek.FRIDAY.equals(d.getDayOfWeek())).max(LocalDate::compareTo)).forEach(o -> System.out.println(o.get()));
    }
}

Former story I made a method to find Premium Friday I made a method to find Premium Friday (Java 8 version)

※※※ I made the year a String because I was thinking, "Would you like to take it from args? But it's annoying to pass it." Also, I feel that the input value in Java is somehow String. Int or java.time.Year is natural.

Recommended Posts

Made a one-liner method for Premium Friday
I made a method to ask for Premium Friday
I made a method to ask for Premium Friday (Java 8 version)
[For programming beginners] What is a method?
I made a plugin for IntelliJ IDEA
A simple and convenient method for HashMap
I made a Diff tool for Java files
When I wanted to create a method for Premium Friday, it was already in the Java 8 standard API
I made a Docker image of SDAPS for Japanese
I made a check tool for the release module
I made a library for displaying tutorials on Android.
abbreviation for ruby method
How to test a private method with RSpec for yourself
Finally, create a method for whether there is any character