Skip to content

Instantly share code, notes, and snippets.

@siosio
Created March 2, 2017 23:03
Show Gist options
  • Save siosio/1aa01396a759196e0ea17e73bc11f213 to your computer and use it in GitHub Desktop.
Save siosio/1aa01396a759196e0ea17e73bc11f213 to your computer and use it in GitHub Desktop.
import java.time.*
import java.time.format.*
import java.time.temporal.*
fun main(args: Array<String>) {
val formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd(E)")
(2017..2020).flatMap { year -> Month.values().map { month -> YearMonth.of(year, month) } }
.filterNot { it.year == 2017 && it.month == Month.JANUARY }
.map(YearMonth::atEndOfMonth)
.map { ymd -> ymd.with(TemporalAdjusters.lastInMonth(DayOfWeek.FRIDAY)) }
.map(formatter::format)
.forEach(::println)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment