Skip to content

Instantly share code, notes, and snippets.

@codingtony
Created March 10, 2016 21:56
Show Gist options
  • Save codingtony/826fe970254c93365909 to your computer and use it in GitHub Desktop.
Save codingtony/826fe970254c93365909 to your computer and use it in GitHub Desktop.
date range in reversed strings
DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder().appendYear(4, 4).appendMonthOfYear(2).appendDayOfMonth(2);
DateTimeFormatter formatter = dtfb.toFormatter();
String s = "20140501";
String e = "20140510";
LocalDate start = LocalDate.parse(s,formatter);
LocalDate end = LocalDate.parse(e,formatter);
StringBuilder sb = new StringBuilder();
while (!start.isAfter(end)) {
formatter.printTo(sb,start);
start = start.plusDays(1);
System.out.println(sb.reverse());
sb.setLength(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment