我有一個created_on =「1324987878」的時間標籤,我想時間爲5:41 PM。如何將sql時間轉換爲hh:mm AM/PM?
回答
使用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
+1我會去與此有關。 – 2011-12-27 12:47:35
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
使用此方法,它會返回時間2011年4月6日上午5:23
public static String getTime(long milliseconds)
{
return DateFormat.format("MMM dd, yyyy h:mmaa", milliseconds).toString();
}
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);
使用SimpleDateFormat
樣品鱈魚Ë
long yourmilliseconds = 1324987878;
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm +a");
Date resultdate = new Date(yourmilliseconds);
System.out.println(sdf.format(resultdate));
Thnx其漂亮的代碼將第二個轉換爲millis – 2012-01-03 14:58:12
- 1. MySQL將時間轉換爲HH:MM
- 2. 如何將這毫秒轉換爲時間(hh:mm a)?
- 3. 如何將數值轉換爲時間(hh:mm)在R中?
- 4. 如何將字符串HH:MM轉換爲Joda持續時間?
- 5. 工作時間calc - 如何將小數轉換爲「hh:mm」?
- 6. 時間轉換爲HH:MM PM/AM格式
- 7. 使用javascript將十進制時間轉換爲hh:mm格式
- 8. 將時間從hh:mm:ss轉換爲hh:mm in java
- 9. 如何將SQL Server 2008中的varchar時間轉換爲時間
- 10. 在SQL Server中轉換爲HH:MM
- 11. 轉換HH:MM字符串時間
- 12. 如何將日期時間與偏移量轉換爲MM/dd/yyyy hh:mm
- 13. 將AM/PM時間轉換爲標準時間格式hh:mm用C#
- 14. SQL將int轉換爲時間
- 15. SQL將INT轉換爲時間
- 16. 將joda LocalTime轉換爲sql時間
- 17. 將時間(7)轉換爲bigint T-SQL
- 18. SQL Server:以hh:mm am/pm格式轉換時間
- 19. 將dd-mm-yyyy hh:mm轉換爲MySQL TIMESTAMP
- 20. 將分鐘數轉換爲hh:mm
- 21. 如何將時間量轉換爲秒?
- 22. 如何將int64轉換爲時間戳
- 23. 如何將此1471323637轉換爲時間
- 24. SQL中的數據格式(將分鐘轉換爲HH:MM格式)
- 25. 將今天的HH:MM am/pm轉換成Bash的時間
- 26. 如何將Sql Server 2008 DateTimeOffset轉換爲日期時間
- 27. 如何將SQL時間記錄轉換爲秒?
- 28. 如何將日期時間轉換爲t-sql中的月數?
- 29. 如何將日期時間字符串轉換爲sql格式?
- 30. 如何將localDatetime轉換爲sql日期時間
@mithun的不同不是在轉換HH:MM:AM – 2011-12-27 12:33:34