TimeZoneInterceptor is now called Samay and has moved to a new repository at https://github.com/dineshsolanki/samay.
Please visit the new Samay repository for the latest updates, features, and documentation.
We welcome you to use Samay for all your timezone needs in Spring Boot applications! It provides the same seamless timezone handling capabilities and more.
Thank you for your interest in TimeZoneInterceptor! We hope you enjoy Samay. Let us know if you have any questions.
π TimeZoneInterceptor is a Java library for Spring Boot that provides automatic handling of timezone information in incoming HTTP requests. It allows you to extract and store the timezone from a custom header, making it easily accessible in your application's controller or service methods.
- β¨ Automatic extraction of timezone information from a custom header in incoming requests.
- 𧡠Stores the timezone information in a
ThreadLocal
variable, accessible within the same request thread. - π Seamless integration with Spring Boot applications.
- βοΈ Customizable header to change where it looks for timezone
Add the following dependency to your project's pom.xml
to use TimeZoneInterceptor:
<dependency>
<groupId>io.github.dineshsolanki</groupId>
<artifactId>TimeZoneInterceptor</artifactId>
<version>RELEASE</version>
</dependency>
TimeZoneInterceptor is available on Maven Central.
By default, TimeZoneInterceptor expects the timezone information to be provided in the X-TimeZone
header of incoming requests. You can customize the header name by adding the following property to your application.properties
:
time-zone-interceptor.header-name=Your-Custom-TimeZone-Header
In your Spring Boot application's controller or service methods, you can access the timezone information using the TimeZoneInterceptor.getTimeZone()
method:
import io.github.dineshsolanki.TimeZoneInterceptor;
@RestController
public class YourController {
@GetMapping("/your-endpoint")
public ResponseEntity<String> yourEndpoint() {
TimeZone timeZone = TimeZoneInterceptor.getTimeZone();
// Your logic using the timeZone information
return ResponseEntity.ok("Endpoint executed with timezone: " + timeZone.getID());
}
}
TimeZoneInterceptor automatically registers the interceptor in Spring Boot applications using Spring Boot's auto-configuration feature. You don't need to explicitly configure the interceptor.
The library automatically cleans up the ThreadLocal
storage after the request is processed. You don't need to worry about manual cleanup.
TimeZoneInterceptor is distributed under the GPL-3 License. See LICENSE for more information.
π€ Contributions are welcome! If you encounter any issues, have suggestions, or want to contribute, please feel free to open an issue or submit a pull request.
To build the library from source, clone the repository and run:
mvn clean install
This will build and install the library into your local Maven repository.
git clone https://github.com/DineshSolanki/TimeZoneInterceptor.git
cd TimeZoneInterceptor
mvn clean install
Discover the world of effortless timezone retrieval with TimeZoneInterceptor! π Simplify your Spring Boot applications and say goodbye to timezone-related headaches. Let TimeZoneInterceptor take care of the heavy lifting, so you can focus on creating amazing applications. Give it a try and see the difference today! π
For any queries, support, or discussions, don't hesitate to join our vibrant community! π We look forward to having you onboard! Happy coding! π¨βπ»π©βπ»