2013-11-01 2 views
0

웹 서비스에서 시간과 함께 목록을 표시합니다. 내가이 예 "12시 56분"표시 시간 형식

처럼 시간을 표시하려면이 내 코드입니다 :

for (int i = 0; i < time.length(); i++) 
{ 
    JSONObject list_time = tab.getJSONObject(i); 

    String time_str = list_time.getString("time-string"); 

// Convert String to Date 
SimpleDateFormat df = new SimpleDateFormat("HH:mm"); 
Date time_to_time = df.parse(time_str); 

myList.add(new Model(id, time_to_time)); 

} 

하지만이있어 : 난 그냥 12시 56분을 표시 할

Thu Jan 01 12:56:00 UTC+01:00 1970 

을, 도와주세요.

답변

0

Date 개체로 구문 분석 중이므로 String으로 구문 분석하십시오. 다음을 사용할 수 있습니다.

public String getFormatedStringTime(Date date) 
{ 
    SimpleDateFormat df = new SimpleDateFormat("HH:mm"); 
    return df.format(date); 
}