2016-06-28 43 views
0

我有一個java項目的問題。如何將org.joda.time.DateTime轉換爲com.mindfusion.common.DateTime

我不得不轉換Stringcom.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

任何想法?

回答

1

看起來你只是想調用構造函數指定所有各個領域:

a.setStartTime(new com.mindfusion.common.DateTime(
    d2.getYear(), d2.getMonthOfYear(), d2.getDayOfMonth(), 
    d2.getHourOfDay(), d2.getMinuteOfHour(), d2.getSecondOfMinute()); 

注意,它不會出現有任何時區支持,這多少有些令人擔憂...

+0

你是對的,我也要添加時區(我想要格林威治標準時間) – taleporos

+0

我在每一個'.get()'exept'.getYear()' – taleporos

+0

@taleporos:編輯getters ...但我不'我知道你的意思是「我還要添加時區」 - 關鍵是'mindfusion'版本沒有*時區,就我所見。 (對於一個「複雜的」日期/時間API,它對我來說看起來相當糟糕......) –