![](/img/trans.png)
[英]How to convert from org.joda.time.DateTime to java.time.ZonedDateTime
[英]How to convert org.joda.time.DateTime to com.mindfusion.common.DateTime
我有一個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());
請注意,它似乎沒有任何時區支持,這有點令人擔憂...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.