gpt4 book ai didi

java - 确定日期是否为工作日/周末java

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:58:09 26 4
gpt4 key购买 nike

<分区>

我试图让它比较星期几,如果是周末则执行操作(尚未实现)但如果我输入今天的日期 25/11/2016 或明天,这是2016 年 11 月 26 日星期六,它仍然只打印“WEEKDAY”。它不起作用,我被卡住了:/

public static void calcDatePrice(String a, boolean b, double c){
System.out.println("CALC PRICE METHOD: " + a);
Double price;
Date d1 = new Date(a);

Calendar c1 = Calendar.getInstance();
c1.setTime(d1);
System.out.println(c1.get(Calendar.DAY_OF_WEEK));

if ((c1.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
|| (Calendar.DAY_OF_WEEK == Calendar.SUNDAY)) { //or sunday
System.out.println("WEEKEND PRICE");
}else {
System.out.println("WEEKDAY");
}
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com