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

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

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(price1.compareTo(new BigDecimal(0)) == 0 && price2.compareTo(new BigDecimal(0)) != 0){
            System.out.println("111");
        }else {
            System.out.println("222");
        }

    }
}

 

posted on 2023-04-10 23:06  oktokeep  阅读(105)  评论(0编辑  收藏  举报