如何确定今天的日期是否是本月的第一天。比如说,今天是2015年5月24日,但不是这个月的第一天。获得输出的最佳方法是什么。
发布于 2015-05-24 15:20:26
提取“日”部分并将其与1进行比较:
if (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == 1) {
System.out.println ("Today is the first day of the month");
}发布于 2015-05-24 15:19:16
检查是否是一个月中的一个月,如:
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_MONTH);
if (day == 1) {
// first day of the month.
}发布于 2015-05-25 04:16:02
使用尤达
boolean isFirstDay = new DateTime(dateObject).getDayOfMonth() == 1;
if(isFirstDay) {
// do whatever
} else {
// whatever
}https://stackoverflow.com/questions/30425076
复制相似问题