package com.shucha.deveiface.biz.utils;
import org.apache.commons.lang3.StringUtils;
public class time {
private static final String yearPattern = "^2[0-9]{3}$";
private static final String monthPattern = "^2[0-9]{3}-(0?[1-9]|1[0-2])$";
private static final String janPattern = "(0?[13578]|1[02])-(0?[1-9]|[12][0-9]|3[01])";
private static final String febPattern = "0?2-(0?[1-9]|[12][0-9])";
private static final String aprPattern = "(0?[469]|11)-(0?[1-9]|[12][0-9]|30)";
private static final String dayPattern = String.format("^2[0-9]{3}-(%s|%s|%s)$", janPattern, febPattern, aprPattern);
private static final String hourFormat = String.format("^2[0-9]{3}-(%s|%s|%s) ([01][0-9]|2[0-3]):00:00$", febPattern, janPattern, aprPattern);
private static final String timeFormat = String.format("^2[0-9]{3}-(%s|%s|%s) ([01][0-9]|2[0-3])(:[0-5][0-9]){2}$", febPattern, janPattern, aprPattern);
public static void main(String[] args) {
String ary[] = {"gg","2365"};
System.out.println(StringUtils.join(ary, "-"));
System.out.println("2000".matches(yearPattern));
System.out.println("2999".matches(yearPattern));
System.out.println("1999".matches(yearPattern));
System.out.println("20001".matches(yearPattern));
System.out.println("200".matches(yearPattern));
System.out.println("2000-11".matches(monthPattern));
System.out.println("2000-01".matches(monthPattern));
System.out.println("2000-1".matches(monthPattern));
System.out.println("2000-13".matches(monthPattern));
System.out.println("2000-00".matches(monthPattern));
System.out.println("2000-11-1".matches(dayPattern));
System.out.println("2000-11-01".matches(dayPattern));
System.out.println("2000-11-31".matches(dayPattern));
System.out.println("2000-11-00".matches(dayPattern));
System.out.println("2000-11-29".matches(dayPattern));
System.out.println("2000-2-29".matches(dayPattern));
System.out.println("2000-2-30".matches(dayPattern));
System.out.println("2000-11-1 18:60:00".matches(hourFormat));
System.out.println("2000-11-1 18:00:10".matches(hourFormat));
System.out.println("2000-1-1 18:00:00".matches(hourFormat));
System.out.println("2000-11-1 28:00:00".matches(hourFormat));
System.out.println("2000-11-1 08:00:00".matches(hourFormat));
System.out.println("2000-11-1_18:00:00".matches(hourFormat));
System.out.println("2000-11-1 08:00:00".matches(timeFormat));
System.out.println("2000-11-1 08:10:00".matches(timeFormat));
System.out.println("2000-11-1 08:00:50".matches(timeFormat));
System.out.println("2000-11-1 08:00:70".matches(timeFormat));
}
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战