我有一个日期实例,如何将其转换为本地时区?
Date meetingStartDate = new SimpleDateFormat(Constants.DATE_FORMATE_CURRENT, Locale.ENGLISH).parse(model.StartDateTimeUtc);
答案 0 :(得分:0)
SimpleDateFormat df = new SimpleDateFormat(Constants.DATE_FORMATE_CURRENT, Locale.ENGLISH);
df.setTimeZone(TimeZone.getDefault());
df = new SimpleDateFormat(Constants.DATE_FORMATE_CURRENT, Locale.ENGLISH);
df.setTimeZone(TimeZone.getDefault());
date == null ? dateStr : df.format(meetingStartDate );
答案 1 :(得分:0)
您可以使用以下代码在当地时区获取时间
Date meetingStartDate = new SimpleDateFormat(Constants.DATE_FORMATE_CURRENT, Locale.ENGLISH).parse(model.StartDateTimeUtc);
DateFormat formatter= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss Z");
formatter.setTimeZone(TimeZone.getDefault());
System.out.println(formatter.format(meetingStartDate));