我对 Java 平台非常初学者和陌生。我有以下 3 个简单的 Java 日期差计算函数。我想在所有 3 种方法中排除以下计算中的周末。任何人都可以帮助如何在以下 dateDiff 计算中排除周末吗?
public static String getDatesDiff(String date1, String date2) {
String timeDiff = "";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d1 = null;
Date d2 = null;
try {
d1 = format.parse(date1);
d2 = format.parse(date2);
long diff = d2.getTime() - d1.getTime();
timeDiff = ""+diff;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return timeDiff;
}
Run Code Online (Sandbox Code Playgroud)
public static String getDatesDiffAsDays(String date1, String date2) {
String timeDiff = ""; …Run Code Online (Sandbox Code Playgroud)