Skip to content

Instantly share code, notes, and snippets.

@Crydust
Created September 3, 2013 13:08
Show Gist options
  • Save Crydust/6423668 to your computer and use it in GitHub Desktop.
Save Crydust/6423668 to your computer and use it in GitHub Desktop.
instantiate a Calendar including timezone, locale and milliseconds
import java.util.Calendar;
import java.util.GregorianCalendar;
public class CalendarApp {
public static void main(String[] args) {
// 2013/09/03 11:46:00.000 UTC
Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"), Locale.ENGLISH);
cal.set(2013, 8, 3, 11, 46, 0);
cal.set(Calendar.MILLISECOND, 0);
long epoch = cal.getTimeInMillis();
System.out.printf("cal = %s%n", cal);
System.out.printf("epoch = %s%n", epoch);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment