【发布时间】:2013-10-12 13:39:04
【问题描述】:
我正在尝试获取当前日期值(例如 12),然后将其分配给一个变量(例如今天 = 12)。
DateFormat DateFormat= new SimpleDateFormat ("dd");
//get current day time with Date()
Date day= new Date ();
int day1 = Integer.valueOf(day);
或者
DateFormat DateFormat= new SimpleDateFormat ("dd");
//get current day time with Date()
Date day= new Date ();
int day1 = day;
但它没有工作:(
还有其他方法吗?
抱歉,在我的预览问题中没有充分阐明含义:)
【问题讨论】:
-
你认为你在做什么?你看过
Date的javadoc吗? -
你的问题标题应该是How to get the day from a Date variable as int?
标签: java int simpledateformat