2015-12-02 77 views
0

我有一個字符串,意思是一個日期。它看起來像這樣:Android的日期字符串

/Date(1448880305230+0200)/

因此,如何將它轉換爲日曆或任何類型的日期?

+0

看看手冊:HTTP://開發商。 android.com/reference/java/text/SimpleDateFormat.html – durbnpoisn

+0

看起來像一個具有時區偏移的紀元時間戳 –

回答

1

以上你的問題並不像unixtime,但是從技術上來講,你可以使用SimlpeDateFormat格式化你的約會像這樣的字符串:

long unixSeconds = 1372339860; 
// *1000 is to convert seconds to milliseconds 
Date date = new Date(unixSeconds*1000L); 
// the format of your date 
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); 
String formattedDate = sdf.format(date); 
//Log it in 
//System.out.println(formattedDate); 
//Log.d(formattedDate);