| | |
| | | */ |
| | | public static final String URL_PATTERN = "yyyyMMddHHmmss"; |
| | | |
| | | /** |
| | | * 日期格式 |
| | | */ |
| | | public static final String date_PATTERN = "yyyy-MM-dd"; |
| | | |
| | | public static final String zoneStr = "Asia/Shanghai"; |
| | | |
| | | public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); |
| | | public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); |
| | | public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); |
| | | public static final DateTimeFormatter DateFormatter = DateTimeFormatter.ofPattern(date_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); |
| | | public static final DateTimeFormatter urlFormatter = DateTimeFormatter.ofPattern(URL_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); |
| | | |
| | | public static String yyyy_MM_dd_HH_mm_ssToISO8601(String formatTime) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 时间戳 转 yyyy_MM_dd_HH_mm_ss |
| | | */ |
| | | public static String timestampTo_yyyy_MM_dd_HH_mm_ss(long timestamp) { |
| | | Instant instant = Instant.ofEpochSecond(timestamp); |
| | | return formatter.format(LocalDateTime.ofInstant(instant, ZoneId.of(zoneStr))); |
| | | } |
| | | |
| | | /** |
| | | * 时间戳 转 yyyy_MM_dd |
| | | */ |
| | | public static String timestampTo_yyyy_MM_dd(long timestamp) { |
| | | Instant instant = Instant.ofEpochMilli(timestamp); |
| | | return DateFormatter.format(LocalDateTime.ofInstant(instant, ZoneId.of(zoneStr))); |
| | | } |
| | | |
| | | /** |
| | | * 获取当前时间 |
| | | * @return |
| | | */ |