Skip to content

Instantly share code, notes, and snippets.

@supernovaplus
Last active September 29, 2020 12:29
Show Gist options
  • Save supernovaplus/a309bccd92e6874059dda0abe1b4e943 to your computer and use it in GitHub Desktop.
Save supernovaplus/a309bccd92e6874059dda0abe1b4e943 to your computer and use it in GitHub Desktop.
printBonusDatesBetween
import java.text.SimpleDateFormat;
import java.util.*;
public class Main {
static void printBonusDatesBetween(int fromYear, int toYear) {
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal = Calendar.getInstance();
cal.set(fromYear, 0, 1);
while(Integer.valueOf(cal.get(Calendar.YEAR)) <= toYear) {
String[] arrOfStr = format1.format(cal.getTime()).split("-", 3);
StringBuilder str = new StringBuilder();
str.append(arrOfStr[0]);
str.reverse();
if( String.valueOf(str).equals((String.valueOf(arrOfStr[1]) + String.valueOf(arrOfStr[2]))) ){
System.out.println( format1.format(cal.getTime()) );
}
cal.add(Calendar.DATE, 1);
}
}
public static void main(String[] args) {
printBonusDatesBetween(2010, 2015);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment