pse.CalendarUtilglobal with sharing class CalendarUtil Utilities relating to days and dates. EnumsDayOfWeek
Methods
getDayOfWeekglobal static pse.CalendarUtil.DayOfWeek getDayOfWeek(Date dt) Returns the day of the week for the provided Date. Input Parameters
getStartOfWeekglobal static Date getStartOfWeek(Date refDate, pse.CalendarUtil.DayOfWeek weekStartDay) Find the start date of the week containing the requested date. The weekStartDay (e.g. Monday) determines which day is considered to be the start of a week. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. System.debug( pse.CalendarUtil.getStartOfWeek( Date.newInstance(2022, 5, 27), pse.CalendarUtil.DayOfWeek.MONDAY ) ); //2022-05-23 System.debug( pse.CalendarUtil.getStartOfWeek( Date.newInstance(2022, 5, 29), pse.CalendarUtil.DayOfWeek.SUNDAY ) ); //2022-05-29 |