package com.om.utils;

import org.apache.commons.lang.StringUtils;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CommonUtil {

    public static String appVersion(String version){
        String f = "APP_Y_X_V";
        // 获取当前日期
        LocalDate currentDate = LocalDate.now();

        // 将日期转换为时间戳（毫秒）
        long currentTimestamp = currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli();

        String time = "-"+currentTimestamp;

        Integer t = 1;
        Integer z = 0;
        Integer w = 0;

        if (StringUtils.isBlank(version)){

            return f+t+"."+z+"."+w+time;
        }
        String substring = version.substring(9, 14);
        String [] s = substring.split(".");
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        int c = Integer.parseInt(s[2]);
        c = c+1;
        b = b+c/10;
        a = b/10;
        c = c%10;

        return f+a+"."+b+"."+c+time;




    }


}
