I implemented the following method:
private int getWeek(String datum){
SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
Date date = null;
try {
date = format.parse(datum);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone( "Europe/Berlin" ));
calendar.setTime(date);
int week = calendar.get(Calendar.WEEK_OF_YEAR);
return week;
}
But when I call the method with
getWeek("01.01.2017")
it returns 52. But it should be 1. Where is my mistake?
When i call the method with
getWeek("01.01.2016")
it returns 53.