如何在 DELPHI ANDROID 中检查一周的第一天是星期一还是星期日?
How to check if first day of week is Monday or Sunday in DELPHI ANDROID?
在 ANDROID 设备上的 DELPHI 中,是否有一种简单的方法来检查一周的第一天是星期一还是星期日?
GregorianCalendar tepCal = (GregorianCalendar) GregorianCalendar.getInstance();
Date todayDate = new Date();
tepCal.setTime(todayDate);
tepCal.set(Calendar.YEAR, 2016);
tepCal.set(Calendar.MONTH, 10);// November
tepCal.set(Calendar.DAY_OF_MONTH, 3);
dayOfweek = tepCal.get(Calendar.DAY_OF_WEEK) - 1; //It returns 4 (Calendar.DAY_OF_WEEK returns 1 for sunday)
只需使用此代码:
var
Calendar: JCalendar;
UsedFirstDayOfWeek: integer;
begin
//For default locale use code
Calendar := TJCalendar.JavaClass.getInstance(TJLocale.JavaClass.getDefault);
//For US locale (etc UK, ...) use code
Calendar := TJCalendar.JavaClass.getInstance(TJLocale.JavaClass.US);
UsedFirstDayOfWeek:= Calendar.getFirstDayOfWeek;
//Constants used in result
SUNDAY Constant Value: 1 (0x00000001)
MONDAY Constant Value: 2 (0x00000002)
TUESDAY Constant Value: 3 (0x00000003)
WEDNESDAY Constant Value: 4 (0x00000004)
THURSDAY Constant Value: 5 (0x00000005)
FRIDAY Constant Value: 6 (0x00000006)
SATURDAY Constant Value: 7 (0x00000007)
end;
在 ANDROID 设备上的 DELPHI 中,是否有一种简单的方法来检查一周的第一天是星期一还是星期日?
GregorianCalendar tepCal = (GregorianCalendar) GregorianCalendar.getInstance();
Date todayDate = new Date();
tepCal.setTime(todayDate);
tepCal.set(Calendar.YEAR, 2016);
tepCal.set(Calendar.MONTH, 10);// November
tepCal.set(Calendar.DAY_OF_MONTH, 3);
dayOfweek = tepCal.get(Calendar.DAY_OF_WEEK) - 1; //It returns 4 (Calendar.DAY_OF_WEEK returns 1 for sunday)
只需使用此代码:
var
Calendar: JCalendar;
UsedFirstDayOfWeek: integer;
begin
//For default locale use code
Calendar := TJCalendar.JavaClass.getInstance(TJLocale.JavaClass.getDefault);
//For US locale (etc UK, ...) use code
Calendar := TJCalendar.JavaClass.getInstance(TJLocale.JavaClass.US);
UsedFirstDayOfWeek:= Calendar.getFirstDayOfWeek;
//Constants used in result
SUNDAY Constant Value: 1 (0x00000001)
MONDAY Constant Value: 2 (0x00000002)
TUESDAY Constant Value: 3 (0x00000003)
WEDNESDAY Constant Value: 4 (0x00000004)
THURSDAY Constant Value: 5 (0x00000005)
FRIDAY Constant Value: 6 (0x00000006)
SATURDAY Constant Value: 7 (0x00000007)
end;