0
我是新的Android開發。我有這個字符串Android工作室蜇到日期時間格式
String gpsT="102030" // time format HHmmss
String gpsD="240214" // date format ddMMyy
如何將其轉換爲日期時間格式"MMM dd, yyyy HH:mm:ss"
?
預期輸出:Feb 24, 2014 10:20:30
我是新的Android開發。我有這個字符串Android工作室蜇到日期時間格式
String gpsT="102030" // time format HHmmss
String gpsD="240214" // date format ddMMyy
如何將其轉換爲日期時間格式"MMM dd, yyyy HH:mm:ss"
?
預期輸出:Feb 24, 2014 10:20:30
使用以下方法:
public static String convertDate(String date, String dateFormate) {
// here date = gpsD+" "+gpsT;
SimpleDateFormat format = new SimpleDateFormat("ddMMyy HHmmss", Locale.getDefault());
SimpleDateFormat destFormat = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss", Locale.getDefault());
Date destDate;
try {
destDate = format.parse(date);
return destFormat.format(destDate);
} catch (ParseException e) {
e.printStackTrace();
}
return "";
}
TY時間和快速響應!它的工作! :) – 2015-02-24 07:12:36
歡迎Zero_73 – 2015-02-24 07:15:53