I'm using following code. Values (hour, minute, second, date, month, year, day_of_week) are hardcoded for simplicity.
Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, 10);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.DATE, 2);
c.set(Calendar.MONTH, Calendar.APRIL);
c.set(Calendar.YEAR, 2018);
c.setFirstDayOfWeek(Calendar.MONDAY);
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
String date = String.format(Locale.US, "%1$tA %1$tb %1$td %1$tY at %1$tI:%1$tM %1$Tp", c);
Log.e("date", date);
Observation 1
This code prints the the following on the Titanium S1 (Android 4.1.2)
E/date: Monday Mar 26 2018 at 10:00 AM
This code prints the the following on the Moto G4+ (Android 7.0), Moto G5+ (Android 7.0)
E/date: Monday Apr 02 2018 at 10:00 AM
Observation 2 This difference appears only on 2nd April & 2nd July to my knowledge. I am seeing the first day of month is Sunday for both the April and July month. It works fine for rest of the days
Question 1) Does the first day of month (MONDAY) cause this difference? Changing it to SUNDAY seems working on these two days. But I am not sure this works in all the scenarios.
This is affecting users on my app. Please help. Thanks.