Java:将UTC中的日期转换为本地时区 [英] Java:Convert date in UTC to local time zone

查看:76
本文介绍了Java:将UTC中的日期转换为本地时区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有保存在UTC时区的db中的日期。必须将此日期转换为系统本地时区。我研究了stackoverflow中的所有其他问题,但没有一个对我有用。请谁能帮我这个忙。
我只需要在java.utils.Date中输出,因为石英调度程序的startAt()方法仅接受日期。

I have date which is stored in db in UTC timezone. have to convert this date to systems local timezone. I'd looked into all other questions in stackoverflow but non of them works for me. Please can any one help me with this. I need output in java.utils.Date only as startAt() method of quartz scheduler accepts Only Date.

推荐答案

通过研究StackOverFlows问题,找到了石英的DateBuilder类,该类有助于转换时区

By looking into StackOverFlows questions find a class DateBuilder of quartz which helps to translate the timezone

Date startDate = DateBuilder.translateTime(job.getStartDate(), TimeZone.getTimeZone("UTC"), TimeZone.getDefault());

这篇关于Java:将UTC中的日期转换为本地时区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆