判断日期是否为周六周日,BigDecimal比较大小

判断日期是否为周六周日,BigDecimal比较大小代码语言:javascript代码运行次数:0运行复制package com.example.core.mydemo.date;import java.math.BigDecimal;i

判断日期是否为周六周日,BigDecimal比较大小

判断日期是否为周六周日,BigDecimal比较大小

代码语言:javascript代码运行次数:0运行复制
package com.example.core.mydemo.date;

import java.math.BigDecimal;
import java.time.DayOfWeek;
import java.time.LocalDateTime;

/**
 * today=6
 * today2=SATURDAY
 * 周末
 * a+b=300
 * 111
 */
public class DateTest {
    public static void main(String[] args) {

//        LocalDateTime dateTime = LocalDateTime.now();
        LocalDateTime dateTime = LocalDateTime.of(2023,4,8,0,0,0);
        DayOfWeek week = dateTime.getDayOfWeek();
        System.out.println("today=" + week.getValue());
        System.out.println("today2=" + week);
        if(week==DayOfWeek.SATURDAY || week==DayOfWeek.SUNDAY){
            System.out.println("周末");
        }else {
            System.out.println("工作日");
        }

        Integer a = new Integer(100);
        Integer b = new Integer(200);
        System.out.println("a+b="+(a+b));

        /**
         * 如果price1为null或0,则取price2
         */
        BigDecimal price1 = new BigDecimal(0);;
        BigDecimal price2 = new BigDecimal(200);

        if(price1 == null && price2 != null){
            price1 = price2;
            System.out.println("price1=" + price1);
        }

        if(price1pareTo(new BigDecimal(0)) == 0 && price2pareTo(new BigDecimal(0)) != 0){
            System.out.println("111");
        }else {
            System.out.println("222");
        }

    }
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2023-04-10,如有侵权请联系 cloudcommunity@tencent 删除datetimeimportintegersystembigdecimal

发布者:admin,转转请注明出处:http://www.yc00.com/web/1754978975a5223775.html

相关推荐

  • 判断日期是否为周六周日,BigDecimal比较大小

    判断日期是否为周六周日,BigDecimal比较大小代码语言:javascript代码运行次数:0运行复制package com.example.core.mydemo.date;import java.math.BigDecimal;i

    1月前
    160

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信