2011-12-27 76 views

回答

2

使用SimpleDateFormat API。

Date dateObj = new Date(1324987878); 
SimpleDateFormat sdfAM = new SimpleDateFormat("MMM dd, yyyy hh:mm a"); 
System.out.println(sdfAM.format(dateObj)); 

輸出:

Jan 16, 1970 01:33 PM 
+0

+1我會去與此有關。 – 2011-12-27 12:47:35

+0

http://dev.thecellcity.com/~alex/FootballKaki/index.php/api/cheers?n_limit=10&n_offset=0&output=dict我想從json響應它,它在iphone下午5:41怎麼辦? – 2011-12-27 12:54:32

1

使用此方法,它會返回時間2011年4月6日上午5:23

public static String getTime(long milliseconds) 
{ 

     return DateFormat.format("MMM dd, yyyy h:mmaa", milliseconds).toString(); 

    } 
0
long created_on = "1324987878"; 
String pattern = "HH:mm a" 
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern); 

Date date = new Date(created_on); 
// 5:41 PM 
String yourFormatedDate = dateFormat.format(date); 
2

使用SimpleDateFormat

樣品鱈魚Ë

long yourmilliseconds = 1324987878; 
      SimpleDateFormat sdf = new SimpleDateFormat("hh:mm +a"); 

      Date resultdate = new Date(yourmilliseconds); 
      System.out.println(sdf.format(resultdate)); 
+0

Thnx其漂亮的代碼將第二個轉換爲millis – 2012-01-03 14:58:12