package jlifereptileserver;

import com.reptileclient.jlifeapp.util.OkHttpUtil;
import org.springframework.util.ObjectUtils;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.regex.Pattern;

public class Test {




    @org.junit.Test
    public void test2() {
        String s = LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME).split("T")[1].substring(0, 5);
        System.out.println(s);
    }

    @org.junit.Test
    public void test3() {
        String str = "空调+冰箱 1+1清洁单人3小时 到家服务 鲸致生活";
        String regEx_special = "[\\u00A0]";
        Pattern compile = Pattern.compile(regEx_special, Pattern.CASE_INSENSITIVE);
        System.out.println(compile.matcher(str).replaceAll("").trim());
    }

    public static String getFileDir(String dir) {
        String dayDir = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")).substring(4);
        String osName = System.getProperty("os.name");
        String storeDir = "";
        if (null == osName) {
            osName = "";
        }
        if (osName.toLowerCase().contains("win")) {
            if (ObjectUtils.isEmpty(storeDir))
                storeDir = "D:\\data0\\" + dayDir + "\\" + dir;
        } else if (osName.toLowerCase().contains("mac")) {
            storeDir = "../tmp/" + dayDir + "/";
        } else {
            storeDir = "/data0/file/" + dayDir + "/";
        }
        return storeDir;
    }

    @org.junit.Test
    public void test4() {
        long lastMonth = LocalDateTime.now().minusMonths(12).atZone(ZoneId.systemDefault()).toEpochSecond() * 1000;
        long now = LocalDateTime.now().atZone(ZoneId.systemDefault()).toEpochSecond() * 1000;
        System.out.println("last = " + lastMonth);
        System.out.println("now = " + now);
    }

    @org.junit.Test
    public void test5() {
        String order = "DD000001";
        // 提取出order中的数字并+1
        String substring = order.substring(2);
        int i = Integer.parseInt(substring);
        System.out.println(i);
        System.out.println("DD" + String.format("%06d", i + 1));

    }
}
