2011-12-27 72 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