当前位置:网站首页>Kotlin - verify whether the time format is yyyy MM DD hh:mm:ss
Kotlin - verify whether the time format is yyyy MM DD hh:mm:ss
2022-07-02 06:35:00 【Xiao Ming Yuan】
Regular matching
fun valiDateTimeWithLongFormat(timeStr: String): Boolean {
val format = "((19|20)[0-9]{2})-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01]) " + "([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]"
var pattern = Pattern.compile(format)
var matcher = pattern.matcher(timeStr)
if (matcher.matches()) {
pattern = Pattern.compile("(\\d{4})-(\\d+)-(\\d+).*")
matcher = pattern.matcher(timeStr)
if (matcher.matches()) {
val y = Integer.valueOf(matcher.group(1))
val m = Integer.valueOf(matcher.group(2))
val d = Integer.valueOf(matcher.group(3))
if (d > 28) {
val c = Calendar.getInstance()
c.set(y, m - 1, 1)
val lastDay = c.getActualMaximum(Calendar.DAY_OF_MONTH)
return lastDay >= d
}
}
return true
}
return false
}
边栏推荐
- Warp shuffle in CUDA
- 华为MindSpore开源实习机试题
- Three suggestions for all students who have graduated and will graduate
- 介绍两款代码自动生成器,帮助提升工作效率
- 底层机制Mvcc
- Thread hierarchy in CUDA
- Cglib agent - Code enhancement test
- 日期时间API详解
- Error "list" object is not callable in Web automatic switching window
- The intern left a big hole when he ran away and made two online problems, which made me miserable
猜你喜欢

In depth understanding of JUC concurrency (II) concurrency theory

介绍两款代码自动生成器,帮助提升工作效率

Pytest (1) case collection rules

CUDA中的Warp Shuffle

Ruijie ebgp configuration case

Distributed transactions: the final consistency scheme of reliable messages

Idea announced a new default UI, which is too refreshing (including the application link)

Thread hierarchy in CUDA
![Data science [9]: SVD (2)](/img/2c/f1a8c3ff34ff3f3cc6e26157a32bfd.png)
Data science [9]: SVD (2)

Redis——大Key问题
随机推荐
[daily question 1] write a function to judge whether a string is the string after the rotation of another string.
Kotlin - 验证时间格式是否是 yyyy-MM-dd HH:mm:ss
CUDA中的Warp Shuffle
阿里云MFA绑定Chrome浏览器
程序员的自我修养—找工作反思篇
Vector types and variables built in CUDA
Thread hierarchy in CUDA
In depth understanding of JUC concurrency (II) concurrency theory
kali最新更新指南
Self cultivation of programmers - Reflection on job hunting
数据科学【九】:SVD(二)
Selenium+msedgedriver+edge browser installation driver pit
web自动化切换窗口时报错“list“ object is not callable
Golang -- map capacity expansion mechanism (including source code)
Functions of tensorrt
日志(常用的日志框架)
Win10桌面图标没有办法拖动(可以选中可以打开可以删除新建等操作但是不能拖动)
Latest CUDA environment configuration (win10 + CUDA 11.6 + vs2019)
Name six schemes to realize delayed messages at one go
Mech 3002 explanation