Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

🌐 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.

License

Notifications You must be signed in to change notification settings

DineshSolanki/TimeZoneInterceptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ•’ TimeZoneInterceptor has a new name and home!

This repository is no longer maintained

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

Maven Central GitHub Lines of code

Overview

🌐 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.

Features

  • ✨ 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

Installation

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.

Usage

1. Configuration

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

2. Accessing the Timezone

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());
    }
}

3. Spring Boot Auto-Configuration (Optional)

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.

4. Interceptor Removal

The library automatically cleans up the ThreadLocal storage after the request is processed. You don't need to worry about manual cleanup.

License

TimeZoneInterceptor is distributed under the GPL-3 License. See LICENSE for more information.

Contributions

🀝 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.


For Library Developers

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

TimeZoneInterceptor

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! πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

About

🌐 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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages