Skip to content

Instantly share code, notes, and snippets.

@StefRe
Created May 15, 2017 16:22
Show Gist options
  • Save StefRe/2e03c406c7c0885236bde2205743e47c to your computer and use it in GitHub Desktop.
Save StefRe/2e03c406c7c0885236bde2205743e47c to your computer and use it in GitHub Desktop.
Year vs WeekYear
import java.util.*;
import java.text.SimpleDateFormat;
import java.util.Locale;
public class DstAndLeapSecondsTest{
public static void main(String[] args){
Calendar start, old, curr;
long diff;
start = Calendar.getInstance(Locale.GERMANY);
start.set(Calendar.YEAR, 2010);
start.set(Calendar.MONTH, Calendar.DECEMBER);
start.set(Calendar.DAY_OF_MONTH, 1);
start.set(Calendar.HOUR_OF_DAY,12 );
start.set(Calendar.MINUTE, 0);
start.set(Calendar.SECOND, 0);
start.set(Calendar.MILLISECOND, 0);
SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
old = (Calendar)start.clone();
//old.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
System.out.println("set - " + old.getTimeZone().getDisplayName());
for (int i = 0; i <= 10000; i++){
if( old.get(Calendar.YEAR) != old.getWeekYear() ){
System.out.println(df.format(old.getTime()) + " week " + old.get(Calendar.WEEK_OF_YEAR) + " year " + old.get(Calendar.YEAR) + " weekyear " + old.getWeekYear());
}
old.add(Calendar.DAY_OF_MONTH,1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment