/* BadLuckDays.kt Copyright (c) Kari Laitinen http://www.naturalprogramming.com 2020-10-31 File created. If you want to insert a dollar sign into a Kotlin string, you need to write it like "${'$'}" */ import java.time.* fun main() { val date_of_today = LocalDate.now() // First we create a LocalDate object that contains the 13th day // of current month. This program can also print this, possibly // past, date. var date_to_check = LocalDate.of( date_of_today.getYear(), date_of_today.getMonthValue(), 13 ) var number_of_friday13_dates_to_print = 10 print( "\n The following are Fridays which also are" + "\n the 13th days of a month: \n\n" ) while ( number_of_friday13_dates_to_print > 0 ) { if ( date_to_check.getDayOfWeek() == DayOfWeek.FRIDAY ) { print( String.format( " %1${'$'}tF, %1${'$'}tA\n", date_to_check ) ) number_of_friday13_dates_to_print -- } // The following statement creates a new LocalDate object that // contains the 13th day of the following month. date_to_check = date_to_check.plusMonths( 1 ) } print( "\n\n" ) }