java 工作日,工作時間內的時間增量計算

2021-08-21 14:57:13 字數 2101 閱讀 5766

/**

* @author xiaogang

* @date 2018/7/19 18:01

*/public class dateutil catch (parseexception e)

}/**

* 工作日內時間加法計算

* @param date

* @return

*/public static date addinworkdate(date date,int hour) throws parseexception

private static string checkandfixhm(string time) throws parseexception else if(parse.after(lunchbreak) && parse.before(workgoon))else if(parse.after(offduty))

return hm.format(parse);

}/**

* 計算時間

* 時間校驗

* @param date

* @param millseconds

* @return

*/private static date jumpresttime(date date,integer millseconds) throws parseexception

}else if(calendar.gettime().after(workgoon) || calendar.gettime().equals(workgoon))

}date time = calendar.gettime();

return time;

}/**

* 判斷時間是否超過了最晚下班時間,如果是,新增一天

* @return

*/private static int judgeisaddoneday(date date,integer millseconds) throws parseexception

}return 0;

}private static date jumprestday(date timevar,int amount,integer millseconds) throws parseexception

amount = amount + i1;

if (hm.parse(hm.format(timevar)).after(offduty))

int i = amount / 5;

int dif = amount - (i * 5);

// system.out.println(i+"倍"+(dif > 0 ? "餘"+dif : ""));

int ac = amount;

if (i != 0)

//判斷餘數加上當前時間是否跨越了週末,如果是,再加兩天

// 星期六:7,星期天:1

calendar instance = calendar.getinstance();

instance.clear();

instance.settime(timevar);

int weekint = instance.get(calendar.day_of_week);

if(weekint + dif > 6 || weekint + dif == 1)

calendar.add(calendar.date,ac);

//如果遇到週末,直接加兩天

if (calendar.saturday == calendar.get(calendar.day_of_week)) else if(calendar.sunday == calendar.get(calendar.day_of_week))

date time = calendar.gettime();

return time;

}public static string formatymdhm(date date)

}

@test

public void testdate() throws parseexception

結果:2018-7-24 10:00:00

工作時間,開溜 )

平生這樣一次休假,沒有奔波,只是腦袋空空的待在乙個地方,吃得好,住的好,看看海。沒有wif,沒有email,沒有景點,沒有 所以也沒有任何微博驚喜和別人分享。就是懶懶的,散散的。看著不一樣的海,或漲或退。感覺真是特別好,特別休閒。可是回來後一直調整不過來,沒有覺得神清氣爽的感覺。同事交待的事情記不住...

php獲取一段時間內的法定工作日

首先,需要自己在後台建立乙個表 content cooper 這個結構如下 create table my content cooper id int 11 unsigned not null auto increment comment 節假日記錄表id year tinyint 3 not nu...

工作時間統計工具

因為整天使用計算機,所以大部分的工作都是在計算機前完成的。大部分時間也耗在計算機上了。所以想統計一下每天工作多少時間,基本上就是統計花在計算機上的工作時間。不過好像沒有什麼特別有效而又簡單的方法自動統計工作時間的,所以想就做乙個工具手動填寫,這個工具分幾個部分,一部分是錄入任務型別的工具,將任務根據...