我有一个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