如果日是本月的第一天乔达或Java如何才能返回true? [英] How can Joda or Java returns true if day is the first day of the month?

查看:133
本文介绍了如果日是本月的第一天乔达或Java如何才能返回true?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何乔达或Java可我写的返回boolean值如果今天是本月的第一天的方法吗?就像如果今天的日期是本月的第一天,它将返回真正

How in Joda or Java can I write a method that returns a boolean value if today is the first day of the current month? Like if today's date is the first day of this month, it will return true.

这可能是这样的:

public static boolean isFirstDayOfTheMonth( Date dateToday ){
boolean isFirstDay = false;
//code to check if dateToday is first day of the current month.
returns isFirstDay;
}

感谢你在前进!

推荐答案

使用的Java SE 8:

With Java SE 8:

public static boolean isFirstDayOfTheMonth(LocalDate dateToday ){
  return dateToday.getDayOfMonth() == 1;
}

这篇关于如果日是本月的第一天乔达或Java如何才能返回true?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆