Universal processing method for internationalization time zone conversion
By introducing the time zone information of the user equipment in the request processing process and dynamic time conversion with the configuration time zone of the background system, the time synchronization and consistency problems in cross-time zone environments are solved, and the system's adaptability and user experience are improved.
Patent Information
- Application Number
- CN202411746668.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-25
AI Technical Summary
The prior art is difficult to achieve time synchronization and time information consistency in a cross-time zone environment, especially when processing historical time data or planning for future events, it is easy to cause misalignment or confusion of time data.
By introducing the time zone information of the user equipment in the request processing process and dynamic time conversion is performed in combination with the configuration time zone of the background system, we ensure that the background processing and return time are consistent no matter which time zone the client is located in. The specific steps include the client obtaining the time zone information of the user terminal device, customizing the serializer and deserializer for time zone conversion, and using the global configuration time zone in the background system for unified processing.
It effectively solves the problems of time synchronization and time information consistency in cross-time zone environments, improves the adaptability and universality of the system, reduces the problems of errors and data inconsistencies caused by time zone differences, and improves the user experience and system stability.
Smart Images

Figure CN119696721A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a universal processing method for international time zone conversion. Background Art
[0002] In today's globalized digital environment, cross-time zone collaborative work, information synchronization, and business processing are becoming more and more common. With the popularization of the Internet and the expansion of international business, computer systems need to process time data from different time zones to ensure the accuracy and consistency of operating time, log records, event planning, and other functions in the system. However, due to the existence of different time zones, daylight saving time rules and different definitions of time in different countries around the world, time processing is extremely complex; traditional time processing methods rely on simple time zone offsets and are difficult to cope with complex requirements such as time synchronization and time conversion between multiple users; in addition, when processing historical time data or plans for future events, it is easy to cause misalignment or confusion of time data. Summary of the invention
[0003] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a universal processing method for international time zone conversion.
[0004] To achieve the above object, the present invention adopts the following technical solutions: A general processing method for international time zone conversion includes the following steps: S1: initiate a request; The user initiates a request from the client to the backend system, and the request includes time information; The time information refers to the time information based on the time zone where the user is located.
[0005] S2: The client obtains the time zone where the user terminal device is located; Before the request reaches the backend system, the client obtains the time zone information of the user's current device through the operating system API or the corresponding JavaScript function, and adds the time zone information to the request header; Furthermore, a custom serializer JsonSerializer is provided, wherein the serializer converts the time information contained in the request into the time information corresponding to the time zone of the user according to the time zone information of the user; The client continues to send the request to the background system.
[0006] S3: The backend system extracts time zone information and time information; User-defined deserializer JsonDeserializer; When the user's request reaches the backend system, the deserializer intercepts the user's request and extracts the time zone information in the request header and the time information in the request.
[0007] S4: Convert the extracted time information into the time information of the corresponding time zone of the backend system; Further, the backend system includes a global configuration time zone, which is used to store time information and perform time calculations; Get the global configuration time zone of the background system, and convert the extracted time information into the time information under the global configuration time zone; Specifically, the extracted time string is parsed into a ZonedDateTime date and time object through the ZonedDateTime.parse method; and the date and time object is converted into time information in the globally configured time zone through the withZoneSameInstant method.
[0008] S5: Use the converted time information to obtain data and return it to the user; The backend system uses the select function to query the relevant data in the database based on the converted time information; after querying the corresponding data, it obtains the data and returns the data and time information to the user; The serializer converts the time information from the time information corresponding to the global configuration time zone to the time information corresponding to the time zone in the user request header, and returns the converted time information to the user.
[0009] Compared with the prior art, the present invention has the following beneficial effects: The present invention proposes a universal processing method for international time zone conversion, which can effectively solve the time synchronization and time information consistency problems in a cross-time zone environment. By introducing the time zone information of the user device into the request processing flow and performing dynamic time conversion in combination with the configuration time zone of the background system, it ensures that no matter which time zone the client is located, the time of background processing and return is consistent; When processing historical time data or planning future events, it can flexibly adapt to the conversion requirements of different system time zones and user time zones, improving the adaptability and versatility of the system, reducing erroneous operations and data inconsistencies caused by time zone differences, and improving user experience and system stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 The present invention is a flowchart of the steps of a universal processing method for international time zone conversion. DETAILED DESCRIPTION
[0011] In order to provide a further understanding of the purpose, structure, features, and functions of the present invention, the following detailed description is given in conjunction with the embodiments.
[0012] like Figure 1 As shown, a general processing method for international time zone conversion includes the following steps: S1: initiate a request; The user initiates a request from the client to the background system, and the request includes time information.
[0013] S2: The client obtains the time zone where the user terminal device is located; Before the request reaches the backend system, the client obtains the time zone information of the user's current device through the operating system API or X-Timezone component and adds the time zone information to the request header; Furthermore, a custom serializer JsonSerializer is provided, wherein the serializer converts the time information contained in the request into the time information corresponding to the time zone of the user according to the time zone information of the user; The client continues to send the request to the background system.
[0014] By including the client's time zone information in the request and adjusting the time according to the user's time zone, the time information is always accurate and consistent with the user's local time zone, preventing time zone confusion; The time zone conversion logic is centrally processed through a custom serializer to avoid writing time zone conversion code separately for each time-related operation in the background system; this makes the background time processing more standardized, and the subsequent modification and maintenance of the time zone conversion logic more convenient, reducing the burden on the server.
[0015] S3: The backend system extracts time zone information and time information; User-defined deserializer JsonDeserializer; When the user's request reaches the backend system, the deserializer intercepts the user's request and extracts the time zone information in the request header and the time information in the request.
[0016] S4: Convert the extracted time information into the time information of the corresponding time zone of the backend system; Further, the backend system includes a global configuration time zone, which is used to store time information and perform time calculations; Get the global configuration time zone of the background system, and convert the extracted time information into the time information under the global configuration time zone; Specifically, the extracted time string is parsed into a ZonedDateTime date and time object through the ZonedDateTime.parse method; and the date and time object is converted into time information in the globally configured time zone through the withZoneSameInstant method.
[0017] There is a globally configured time zone in the system, and the time information of all requests will eventually be processed uniformly according to this time zone; when the system processes requests from different regions, all times can be stored and calculated in the same standard time zone, avoiding the confusion caused by different time zone settings.
[0018] S5: Use the converted time information to obtain data and return it to the user; The backend system uses the select function to query the relevant data in the database based on the converted time information; after querying the corresponding data, it obtains the data and returns the data and time information to the user; The serializer converts the time information from the time information corresponding to the global configuration time zone to the time information corresponding to the time zone in the user request header, and returns the converted time information to the user.
[0019] Storing time information in a unified time zone format (such as UTC) can reduce query problems caused by inconsistent time zone storage formats and simplify database design; all data is stored in a standard format, and there is no need to consider time zone differences when querying, just query according to unified standards; improve query efficiency and reduce system burden; avoid time inconsistencies caused by cross-time zone operations or storage errors.
[0020] The present invention has been described by the above-mentioned relevant embodiments, however, the above-mentioned embodiments are only examples for implementing the present invention. It must be pointed out that the disclosed embodiments do not limit the scope of the present invention. On the contrary, changes and modifications made without departing from the spirit and scope of the present invention are all within the scope of patent protection of the present invention.
Claims
1. A universal processing method for international time zone conversion, characterized by: The following steps are involved: S1: initiate a request; The user initiates a request from the client to the backend system, and the request includes time information; S2: The client obtains the time zone where the user terminal device is located; S3: The backend system extracts time zone information and time information; User-defined deserializer JsonDeserializer; When the user's request reaches the backend system, the deserializer intercepts the user's request and extracts the time zone information in the request header and the time information in the request; S4: Convert the extracted time information into the time information of the corresponding time zone of the backend system; The backend system includes a global configuration time zone, which is used to store time information and perform time calculations; Get the global configuration time zone of the background system, and convert the extracted time information into the time information under the global configuration time zone; S5: Use the converted time information to obtain data and return it to the user; The backend system uses the select function to query the relevant data in the database based on the converted time information; after querying the corresponding data, it obtains the data and returns the data and time information to the user.
2. The universal processing method for international time zone conversion as claimed in claim 1, characterized in that: In step S2, before the request reaches the backend system, the client obtains the time zone information of the user's current device through the operating system API or X-Timezone component, and adds the time zone information to the request header; The client continues to send the request to the background system.
3. The universal processing method for international time zone conversion as claimed in claim 1, characterized in that: In step S4, specifically, the extracted time string is parsed into a ZonedDateTime date and time object by using the ZonedDateTime.parse method; and the date and time object is converted into time information in a globally configured time zone by using the withZoneSameInstant method.
4. The universal processing method for international time zone conversion as claimed in claim 1, characterized in that: In step S5, the serializer converts the time information from the time information corresponding to the global configuration time zone to the time information corresponding to the time zone in the user request header, and returns the converted time information to the user.