2 ms·
Ask HN:Converting cron expression from one timezone to UTC in java
Is there any java library which can modify cron expression from one timezone to UTC?
For example:
I need something like this:
newCronExpression = convert (oneCronExpression, fromTimezone, "UTC")
Let me give you one example:
My local timezone is IST i.e. GMT+5.30.
Current local time is: 11:20 AM.
I want a job to run in 45 min of every hour.
So, my cron expression: 45 * * * *
Hence I am expecting my job to run after 25 min ( as starting time is 11:45 AM)
but my job is running as per UTC.
Current time in UTC : 05:50 AM
As per cron expression 45 * * * , the starting time will be 06:45 AM at GMT.
So, the job will be actually started after 55 min.
Expected : After 25 min
Actual : After 55 min
So, if I am converting my local cron expression 45 * * * to 15 * * * * at GMT, then actual waiting period will be same as expected.
The question is how will I convert my local cron expression to GMT for all usecase in my java program.
If you have better approach, please do let me know.
*I can't schedule it as crontab in unix machine. This has to be handled in Java program.
Thanks in advance.