MCPcopy Create free account
hub / github.com/527515025/springBoot / DateTimeUtils

Class DateTimeUtils

abel-util/src/main/java/cn/abel/utils/DateTimeUtils.java:18–283  ·  view source on GitHub ↗

日期util。

Source from the content-addressed store, hash-verified

16 * 日期util。
17 */
18public class DateTimeUtils {
19
20 /**
21 * 一分钟。
22 */
23 public static final int ONE_MINUTE = 60 * 1000;
24
25 /**
26 * 一小时。
27 */
28 public static final int ONE_HOUR = 60 * ONE_MINUTE;
29
30 /**
31 * 一天。
32 */
33 public static final int ONE_DAY = 24 * ONE_HOUR;
34
35
36 public static final String DEFAULT_DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
37 public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd";
38 private static final int ARG_ERROR_CODE = 400;
39 private static final String ARG_ERROR = "输入的参数有误";
40
41
42 /**
43 * 根据给定的格式将时间转为字符串。
44 *
45 * @param dateTime
46 * @param pattern
47 * @return
48 */
49 public static String format(Date dateTime, String pattern) {
50 if (dateTime == null || pattern == null) {
51 return StringUtils.EMPTY;
52 }
53
54 return DateFormatUtils.format(dateTime, pattern);
55 }
56
57 /**
58 * 将时间转为默认格式的字符串。
59 *
60 * @param dateTime
61 * @return
62 */
63 public static String format(Date dateTime) {
64 return format(dateTime, DEFAULT_DATETIME_PATTERN);
65 }
66
67 /**
68 * 根据给定的格式获取当前日期的字符串。
69 *
70 * @param pattern
71 * @return
72 */
73 public static String formatCurrent(String pattern) {
74 return format(new Date(), pattern);
75 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected