/**
* 将"20111013080000"类型的时间字符串转化成"2011年10月13日"格式的字符串
*
* @param time
* 需要转化的时间字符串
* @return 如果time为正常的时间格式,则转化成相应格式的时间, 否则返回null
*/
public static String parseTime1(String time) {
String result = null;
SimpleDateFormat sourceDateFormat = new SimpleDateFormat(SOURCE_PORMAT);
SimpleDateFormat destDateFormat = new SimpleDateFormat(DEST_PORMAT);
try {
Date date = sourceDateFormat.parse(time);
result = destDateFormat.format(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
java时间转换
最新推荐文章于 2022-08-19 11:06:36 发布