AWS Lambda function for calculating business days considering regional holidays and working days patterns.
- Calculate business days across different regions
- Support for various working week patterns:
- Monday-Friday (standard)
- Sunday-Thursday (Middle East)
- Monday-Saturday (Nepal)
- Skip regional holidays using Jollyday library
- ISO 3166-1 alpha-2 country code validation
- JSON request/response format
- Java 21 (minimum required version)
- Gradle 8.14.2
- AWS Lambda runtime
Build the project using Gradle:
./gradlew clean buildTo build and package the Lambda function:
./gradlew packageLambdaThis will create the deployment package at app/build/dist/function.zip. The ZIP contains all class files and dependencies extracted directly into the archive (not as a nested JAR), which is the correct format for AWS Lambda deployment.
Run the test suite:
./gradlew test{
"startDate": "2025-06-13",
"daysToAdd": 5,
"countryCode": "US"
}{
"resultDate": "2025-06-20"
}Calculate business days for Israel (Sunday-Thursday work week):
curl -X POST https://your-api-gateway-url/prod/business-calendar \
-H "Content-Type: application/json" \
-d '{"startDate":"2025-06-12","daysToAdd":3,"countryCode":"IL"}'- 400 Bad Request: Invalid parameters or country code
- 500 Internal Server Error: Processing errors
Deploy the ZIP to AWS Lambda using one of these options:
- Go to the AWS Lambda console
- Create a new function or select an existing one
- In the "Function code" section:
- Choose "Upload from .zip file"
- Upload the
app/build/dist/function.zipfile - Save changes
aws lambda create-function \
--function-name business-calendar \
--runtime java21 \
--handler com.lifenture.functions.BusinessCalendarHandler::handleRequest \
--role arn:aws:iam::123456789012:role/lambda-role \
--zip-file fileb://app/build/dist/function.zipTo update an existing function:
aws lambda update-function-code \
--function-name business-calendar \
--zip-file fileb://app/build/dist/function.zipNote: Replace these values with your configuration:
123456789012: Your AWS account IDlambda-role: Your Lambda execution role
- Fork the repository
- Create your feature branch
- Commit your changes using conventional commits
- Push to the branch
- Create a Pull Request
This project uses the following open-source libraries:
Holiday calculation is powered by Jollyday, a Java library for handling holidays.
- Project: focus-shift/jollyday
- License: Apache License 2.0
- Authors:
- Sven Diedrichsen (Original author)
- Focus Shift Team (Current maintainers)
- Marcel Dix
- Matthias Born
- Andreas Dangel
- Michael Bowler
Special thanks to the Jollyday team for providing and maintaining this excellent holiday calculation library.
This project is licensed under the MIT License - see the LICENSE file for details.
It uses third-party libraries, including components licensed under the Apache License, Version 2.0.