54 lines
1.4 KiB
Java
54 lines
1.4 KiB
Java
package com.prolificinteractive.materialcalendarview;
|
|
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public class CalendarUtils {
|
|
public static Calendar getInstance(Date date) {
|
|
Calendar calendar = Calendar.getInstance();
|
|
if (date != null) {
|
|
calendar.setTime(date);
|
|
}
|
|
copyDateTo(calendar, calendar);
|
|
return calendar;
|
|
}
|
|
|
|
public static Calendar getInstance() {
|
|
Calendar calendar = Calendar.getInstance();
|
|
copyDateTo(calendar, calendar);
|
|
return calendar;
|
|
}
|
|
|
|
public static void setToFirstDay(Calendar calendar) {
|
|
int year = getYear(calendar);
|
|
int month = getMonth(calendar);
|
|
calendar.clear();
|
|
calendar.set(year, month, 1);
|
|
}
|
|
|
|
public static void copyDateTo(Calendar calendar, Calendar calendar2) {
|
|
int year = getYear(calendar);
|
|
int month = getMonth(calendar);
|
|
int day = getDay(calendar);
|
|
calendar2.clear();
|
|
calendar2.set(year, month, day);
|
|
}
|
|
|
|
public static int getYear(Calendar calendar) {
|
|
return calendar.get(1);
|
|
}
|
|
|
|
public static int getMonth(Calendar calendar) {
|
|
return calendar.get(2);
|
|
}
|
|
|
|
public static int getDay(Calendar calendar) {
|
|
return calendar.get(5);
|
|
}
|
|
|
|
public static int getDayOfWeek(Calendar calendar) {
|
|
return calendar.get(7);
|
|
}
|
|
}
|