2011-05-24 14 views
0

私は次の日付があります:私はジョダのDateTimeにこれを変換することができますどのようUTCをDateTimeに変換するにはどうすればよいですか?

2011-05-24T11:40:41Z 

を?

EDIT

DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); 
         Date date = df.parse(aMessage.getString("updated_at")); 
         org.joda.time.DateTime dt = new DateTime(date); 

エラー:

The method parse(String) is undefined for the type DateFormat 
Type mismatch: cannot convert from SimpleDateFormat to DateFormat 

答えて

1

すべての印刷および解析はDateTimeFormatterオブジェクトを使用して行われます。

あなたは、このインスタンスに直接ISODateTimeFormat工場を使用することができるはずです。

String inputDateString = "2011-05-24T11:40:41Z"; 

DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis(); 
DateTime result = fmt.parseDateTime(inputDateString); 
0

使用DatFormat はここでコンパイルされません私のコードです。あなたが使用できる方法はparse()です。ジョダのuser guideから

DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); 
    df.parse("2011-05-24T11:40:41Z"); 
    org.joda.time.DateTime dt = new DateTime(date); 
+0

あなたは私の今回の例を示していることはできますか? –

+0

はい、Joda DateTime –

+0

私は答えをどのように更新しましたか? –

関連する問題