- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要找到上个月的最后一个星期五。这个月是六月。我需要五月的最后一个星期五。在这种情况下(5 月 29 日)。我只能找到当月的最后一个星期五。找到上个月的星期五后,我需要检查从多少天开始。如果距离上周五已经 5 天,则执行任务。希望这是清楚的。如果没有,请询问,我可以更详细地解释。
public class task {
static String lastFriday;
static String dtToday;
public static void main(String[] args) {
//daysInBetween = current day - (last month's friday date)
if (daysInBetween = 5) {
//run program after 5 days
} else { //quit program }
}
// Gets last Friday of the Month
// Need last Friday of previous Month...
public static String getLastFriday() {
Calendar cal = new GregorianCalendar();
cal.set(GregorianCalendar.DAY_OF_WEEK, Calendar.FRIDAY);
cal.set(GregorianCalendar.DAY_OF_WEEK_IN_MONTH, -1);
SimpleDateFormat date_format = new SimpleDateFormat("yyyy/MM/dd");
lastFriday = date_format.format(cal.getTime());
return lastFriday;
}
// Gets today's date
public static String getToday() {
Calendar cal = new GregorianCalendar();
SimpleDateFormat date_format = new SimpleDateFormat("yyyy/MM/dd");
dtToday = date_format.format(cal.getTime());
return dtToday;
}
}
最佳答案
查找last Friday of any month使用方法 -
public Date getLastFriday( int month, int year ) {
Calendar cal = Calendar.getInstance();
cal.set( year, month + 1, 1 );
cal.add( Calendar.DAY_OF_MONTH, -( cal.get( Calendar.DAY_OF_WEEK ) % 7 + 1 ) );
return cal.getTime();
}
您可以使用以下方法找出 2 天之间的差异 -
public int getDifferenceDays(Date d1, Date d2) {
int daysdiff=0;
long diff = d2.getTime() - d1.getTime();
long diffDays = diff / (24 * 60 * 60 * 1000)+1;
daysdiff = (int) diffDays;
return daysdiff;
}
关于java - 查找上个月的最后一个星期五并检查当前日期之间的天数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30627889/
根据 @gordon 的评论进行编辑 --- 假设以下场景 CREATE TABLE card (date_field, numcard, month); INSERT INTO card (date
以下返回我们月份集合中的最后一个成员: TAIL([Date].[Date - Calendar Month].[Calendar Month],1) 我们的多维数据集包含截至昨天(包括昨天)的数据
我需要统计所有用户,上周和上个月的用户,按日期分组。 我已经尝试过 var project = { $project:{ day: { $dayOfMonth: "$updat
我正在使用 Trent Richardson 的优秀 Datetimepicker .但是,我遇到了一个特定问题,该插件的行为不像传统的 jQuery UI Datepicker。 . 当您从一个空白
您好,我需要显示 3 个月(单独)借记的总金额,并将其显示在柱形图上。 (我已包含 session_start 和 $user_id = $_SESSION['user_id']) 而且我认为我的 $
我正在尝试获取上个月(或一周)或给定时间段内所有应用程序使用的移动数据。我想获取移动数据使用历史记录。我看到 android 现在默认情况下这样做。是否可以通过代码获取这些信息? 最佳答案 Is it
我正在尝试从我的数据中获取第一个结果,其中日期等于上个月的日期范围。 这是我的数据库内容的示例 - id date_recorded 1 2016-07-22 15:21:33 2 2016
我有一个时间对象,想找到下一个月/上一个月。加减天数不起作用,因为每个月的天数不同。 time = Time.parse('21-12-2008 10:51 UTC') next_month = ti
我的 Android SQLite 数据库中有这个表: CREATE TABLE statistics (subject TEXT, hits INTEGER, fails INTEGER, date
我正在使用 AWS Cloudfront Java SDK 来自动执行一些任务,其中之一就是使分发无效。我读到前 1000 个失效请求(实际上是路径)是免费的,之后它们 are billed . 我在
我正在构建一个函数,我将根据用户作为参数发送给它的内容动态生成日期。我需要为上周、本周、上个月、本月、过去 7 天、过去 30 天等案例创建日期。由于我要将日期从日期发送到数据库,因此我需要将它们格式
我将 FScalendar 用于上个月和下个月的日历。如何从当前日历中删除上个月/下个月的日期? 最佳答案 您只能隐藏下个月和上个月的日期。 override func viewDidLoad() {
我有一个名为 sales 的表,如下所示: s.no item_sold date 1 soap 25.07.2017 2
我已经通过if else 构建了长距离或传统方式的过滤代码,我需要使用高级 JavaScript 方法(如 filter、map、reduce)来完成 home.html
我想做的是让 NSDate 今天、昨天、本周、上周、本月、上个月变量准备好进行比较,以便在 UITableView 的 titleForHeaderInSection 上添加标题 我想要的是在下面的代
我是一名优秀的程序员,十分优秀!