您的位置:首页 > 其它

字符串转换为时间格式

2010-03-27 15:26 267 查看
/**

* 字符串转换为时间格式

*

* @param tm Timestamp

* @return Timestamp 返回null为无法转换为时间格式

* @exception/throws

* @see AcctPub

* @deprecated

*/

public static String convertTimeToString(Timestamp tm)

{

Calendar cld = Calendar.getInstance(TimeZone.getDefault(),

new Locale("Chinese", "CHINA"));

cld.setTime(tm);

java.lang.StringBuffer strTime = new java.lang.StringBuffer();

strTime.append(cld.get(Calendar.YEAR));

strTime.append("-");

strTime.append(cld.get(Calendar.MONTH) + 1);

strTime.append("-");

strTime.append(cld.get(Calendar.DATE));

strTime.append(" ");

strTime.append(cld.get(Calendar.HOUR_OF_DAY));

strTime.append(":");

strTime.append(cld.get(Calendar.MINUTE));

strTime.append(":");

strTime.append(cld.get(Calendar.SECOND));

return strTime.toString();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: