KJAN KJAN - 1 month ago 11
Android Question

How to check if first day of week is Monday or Sunday in DELPHI ANDROID?

Is there a simple way to check if first day of week is Monday or Sunday in DELPHI on ANDROID device?

Answer

Simply use this code:

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;