Check date time occurs within Business Hours Salesforce Apex

In Salesforce Apex, we can make use of BusinessHours.isWithin() method to check whether the date time is within the business hours or not. Please check the following apex code for reference. Sample Apex Code: