我有一个Java项目问题。
我必须将String
转换为com.mindfusion.common.DateTime
,我要做的就是使用以下代码将其转换为org.joda.time.DateTime
:
org.joda.time.format.DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
org.joda.time.DateTime d2 = formatter.parseDateTime("2/7/2016 12:00:00");
我想这样使用它:
Appointment a = new Appointment();
a.setStartTime(d2);
但是
setStartTime()
需要com.mindfusion.common.DateTime
有任何想法吗?
最佳答案
看起来您只想调用指定所有各个字段的构造函数:
a.setStartTime(new com.mindfusion.common.DateTime(
d2.getYear(), d2.getMonthOfYear(), d2.getDayOfMonth(),
d2.getHourOfDay(), d2.getMinuteOfHour(), d2.getSecondOfMinute());
请注意,它似乎没有任何时区支持,这有点令人担忧。