SimpleDateFormat日期格式化
2013-10-10 21:44
211 查看
public class T { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); SimpleDateFormat newsdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { /** * parse解析的字符要和sdf的日期格式 一致 否则会出现意想不到的结果 * 比如 19900431 模板为yyyyMMdd * 则会输出1990-05-01 因为四月份没有31所以会递进1就成为了05-01 */ Date date = sdf.parse("19900413123020"); System.out.println(newsdf.format(date)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
相关文章推荐
- 《黑马程序员》 日期Data类,日期格式化DateFormat,自定义格式化SimpleDateFormat的使用
- Java日期格式化及其使用例子收集 SimpleDateFormat担当重任,怎样格式化都行
- 用SimpleDateFormat格式化日期和时间
- java综合:SimpleDateFormat格式化日期
- 使用 SimpleDateFormat 类格式化日期
- 使用 SimpleDateFormat 格式化日期和使用printf格式化日期
- SimpleDateFormat格式化日期
- 使用SimpleDateFormat格式化日期
- SimpleDateFormat 日期格式化
- Java中SimpleDateFormat格式化日期用法
- 格式化日期:SimpleDateFormat
- SimpleDateFormat格式化日期时间格式
- SimpleDateFormat格式化日期
- SimpleDateFormat 日期格式化
- SimpleDateFormat格式化日期
- java 使用simpleDateFormat格式化日期 时间
- java 使用simpleDateFormat格式化日期 时间
- SimpleDateFormat格式化日期
- SimpleDateFormat格式化日期
- 使用SimpleDateFormat格式化日期