Android:日历不返回值?
我正在尝试运行这段小代码以返回一个八位整数,以便稍后在 for 循环
中用作搜索函数。问题是它不返回 searchDateToday
的任何值。我错过了什么吗?
final Calendar cal = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
DateToday = formatter.format(cal.getTime()); // YYYYMMDD form -
// Example: 20111010
// = October 10,
// 2011
int searchDateToday = Integer.parseInt(DateToday);
I'm trying to run this little code to return a eight-digit integer
to be used in a for-loop
later on as a search function. Problem is that it doesn't return any values for searchDateToday
. Am I missing something?
final Calendar cal = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
DateToday = formatter.format(cal.getTime()); // YYYYMMDD form -
// Example: 20111010
// = October 10,
// 2011
int searchDateToday = Integer.parseInt(DateToday);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您忘记使用 Date 对象:
You forgot to use the Date object:
用它来获取今天的日期
use this for getting today date