日期将dd-MMM-yyyy转换为dd-MM-yyyy [英] Date convert dd-MMM-yyyy to dd-MM-yyyy in java

查看:172
本文介绍了日期将dd-MMM-yyyy转换为dd-MM-yyyy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述






在Java中,将2011年3月23日至23-03-2011的最简单方法是什么?感谢大家。这似乎解决了这个问题:

  try {
Calendar cal = Calendar.getInstance();
cal.setTime(new SimpleDateFormat(dd-MMM-yyyy)。parse(24-Nov-2002));
SimpleDateFormat sdf = new SimpleDateFormat(dd-MM-yyyy);
System.out.println(sdf.format(cal.getTime()))
} catch(ParseException e){e.printStackTrace();你有没有看过 SimpleDateFormat




What is the simplest way to convert 23-Mar-2011 to 23-03-2011 in Java?


Thanks everyone. This seem to solve the issue:

try { 
Calendar cal = Calendar.getInstance(); 
cal.setTime(new SimpleDateFormat("dd-MMM-yyyy").parse("24-Nov-2002")); 
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
System.out.println(sdf.format(cal.getTime())); 
} catch (ParseException e) { e.printStackTrace(); }

解决方案

Have you looked at SimpleDateFormat ?

这篇关于日期将dd-MMM-yyyy转换为dd-MM-yyyy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆