Install any skill in seconds. Free to start, no credit card required.
Get Started Free →doccker/time-zone-safety
当代码出现 LocalDate.now() / LocalDateTime.now() / Instant.now() / new Date() / Date.now() / time.Now() 等"当前时间"调用,或涉及周/月/日起点、跨时区比较、数据库时间字段时触发。防止生产环境时区漂移导致的统计错乱。
Passed 22 of 22 test cases with the skill, and 20 of 22 without it.
2 fixed20 passed either way0 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 2 test cases the skill fixed. Same model, same prompt, with and without the skill.
Write a bash shell command pipeline to search `src/main/java/` for unzoned `LocalDate.now()` or `LocalDateTime.now()` calls while filtering out legitimate constant declarations.
| Checked | Without skill | With skill |
|---|---|---|
| greps for bare LocalDate.now or LocalDateTime.now calls in src/main/java | Passed | Passed |
| filters out TimeConstants or configuration files using grep invert match | Missed | Passed |
The instructions your model reads when the skill loads.
服务端代码里,"当前时间"几乎从不应该裸调。一个 docker 镜像默认 UTC、一个生产机配置 Asia/Shanghai,同一份代码跑出来的"本周起点"就差 8 小时。
配套:
query-performance-safety(性能) /multi-tenant-safety(隔离)
.now() 依赖 JVM 默认时区场景: LocalDate.now() / LocalDateTime.now() / Instant.now() / new Date() 不传时区
LocalDate.now() 在 UTC 服务器上返回的"今天"比业务时区少 1 天(凌晨场景)LocalDateTime.now() 拿到的是 JVM 默认时区时间,docker base image 经常默认 UTC// ❌ 错误:依赖 JVM 默认时区
LocalDateTime weekStart = LocalDate.now()
.with(DayOfWeek.MONDAY)
.atStartOfDay();
// ❌ 错误:跨日切换的统计依赖默认时区
LocalDate today = LocalDate.now();
List<Order> todayOrders = orderRepository.findByCreatedAtAfter(today.atStartOfDay());
// ❌ 错误:Date 用默认时区
Date now = new Date();
项目级业务时区常量 + 所有 .now() 显式传入:
test cases passed, vs 20 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.