在Java上将日期格式转换为其他格式 [英] Converting Date format to other format on Java
本文介绍了在Java上将日期格式转换为其他格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在用Java上的GWT开发应用程序.我在网站上的项目中使用了日历工具.当我选择任何日期时,请给我这种格式(13年8月23日).
I have been developing application with GWT on Java. I used calendar tool for my project on this site. When i select any date, give this format (23-Aug-13) to me.
我使用以下代码:
final DateField txtBirthofDay = new DateField("Birth of Day", "dob", 190);
txtBirthofDay.setValue(new Date());
我想将此日期插入数据库.因此,我必须转换此格式(2013-08-23).我之前互相转换了许多日期格式,但没有转换字符串类型(八月).
I want to insert this date to database. So, I have to convert this format (2013-08-23). I converted lots of date format each other before but I didn't convert string type (Aug).
推荐答案
SimpleDateFormat将日期格式化为给定的模式
SimpleDateFormat formats your Date to the given pattern
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(sdf.format(new Date()));
这篇关于在Java上将日期格式转换为其他格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文