Skip to content

Commit

Permalink
clear calendar before use
Browse files Browse the repository at this point in the history
  • Loading branch information
jdereg committed Oct 7, 2023
1 parent 7dc9887 commit 11d1f11
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public SafeSimpleDateFormat(String format)
DateFormat dateFormat = getDateFormat(_format);
// Reset for new instance
Calendar cal = Calendar.getInstance();
cal.clear();
dateFormat.setCalendar(cal);
dateFormat.setLenient(cal.isLenient());
dateFormat.setTimeZone(cal.getTimeZone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void testSetCalendar() throws Exception
cal.clear();
cal.setTime(then);
assertEquals(2013, cal.get(Calendar.YEAR));
assertEquals(2, cal.get(Calendar.MONTH)); // Sept
assertEquals(2, cal.get(Calendar.MONTH)); // March
assertEquals(31, cal.get(Calendar.DAY_OF_MONTH));
assertEquals(0, cal.get(Calendar.HOUR_OF_DAY));
assertEquals(0, cal.get(Calendar.MINUTE));
Expand Down

0 comments on commit 11d1f11

Please sign in to comment.