J2ME:从 DateField 中仅获取年/月/日
我正在尝试使用 dateField 来显示日历中选择的年份、月份或日期。
public DateField getDateField() {
dateField = new DateField("dateField", DateField.DATE);
dateField.setDate(new java.util.Date(System.currentTimeMillis()));
}
然后我想使用此代码,但不是长日期“Thu Oct 07 00:00:00 GMT+02:00 2010”,我只想查看选择的月份,例如“十月”或“ 10”等。
String month = dateField.getDate().toString();
System.out.println("Selected month: " + month);
我在这个 dateField 上找不到任何好的东西...如果在 dateField 中选择了特定日期,我想获得像“2010-10-05”这样的短日期。
I'm trying to use dateField to display which year, month or day has been selected in the calendar.
public DateField getDateField() {
dateField = new DateField("dateField", DateField.DATE);
dateField.setDate(new java.util.Date(System.currentTimeMillis()));
}
Then I'd like to use this code, but instead of the long date "Thu Oct 07 00:00:00 GMT+02:00 2010" I would like to just see what month has been selected, like "October" or "10" etc.
String month = dateField.getDate().toString();
System.out.println("Selected month: " + month);
I can't find anything good on this dateField thing... I want to get the short date like "2010-10-05" if that specific date has been selected in the dateField.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)