Skip to content

Instantly share code, notes, and snippets.

@ainvyu
Created December 29, 2015 02:45
Show Gist options
  • Save ainvyu/1bc127164eab153f6498 to your computer and use it in GitHub Desktop.
Save ainvyu/1bc127164eab153f6498 to your computer and use it in GitHub Desktop.
Date sample
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
/**
* Created by vine on 15. 5. 27..
*/
public class Main {
public static void main(String args[]) {
String pattern = "yyyyMMdd";
String thisTimeZone = DateTimeZone.UTC.getID(); //"UTC";
DateTimeFormatter formatter = DateTimeFormat.forPattern(pattern)
.withZone(DateTimeZone.forID(thisTimeZone));
DateTime dateTime = formatter.parseDateTime("20160101");
List<String> days = new ArrayList<String>();
for (int i = 0; i < 30; ++i) {
days.add(formatter.print(dateTime));
dateTime = dateTime.plusDays(1);
}
System.out.println(days);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment