pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/code4everything/util/commit/6eff66a49db88d3001f5eecfbf398545fb0d62be

15.css" /> add converter for date to timestamp · code4everything/util@6eff66a · GitHub
Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Commit 6eff66a

Browse files
committed
add converter for date to timestamp
1 parent 9dcb100 commit 6eff66a

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

src/main/java/com/zhazhapan/util/DateUtils.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,60 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
1717

1818
private DateUtils() {}
1919

20+
/**
21+
* 将日期转换成时间戳
22+
*
23+
* @param date {@link Date}
24+
*
25+
* @return {@link Timestamp}
26+
*
27+
* @since 1.1.1
28+
*/
29+
public static Timestamp convertDateToTimestamp(Date date) {
30+
return convertDateToTimestamp(date, getCurrentTimestamp());
31+
}
32+
33+
/**
34+
* 将日期转换成时间戳
35+
*
36+
* @param date {@link Date}
37+
* @param elseValue 日期为空返回默认时间戳
38+
*
39+
* @return {@link Timestamp}
40+
*
41+
* @since 1.1.1
42+
*/
43+
public static Timestamp convertDateToTimestamp(Date date, Timestamp elseValue) {
44+
return Checker.isNull(date) ? elseValue : new Timestamp(date.getTime());
45+
}
46+
47+
/**
48+
* 将日期转换成时间
49+
*
50+
* @param date {@link Date}
51+
*
52+
* @return {@link Time}
53+
*
54+
* @since 1.1.1
55+
*/
56+
public static Time convertDateToTime(Date date) {
57+
return convertDateToTime(date, new Time(System.currentTimeMillis()));
58+
}
59+
60+
/**
61+
* 将日期转换成时间
62+
*
63+
* @param date {@link Date}
64+
* @param elseValue 日期为空返回默认时间
65+
*
66+
* @return {@link Time}
67+
*
68+
* @since 1.1.1
69+
*/
70+
public static Time convertDateToTime(Date date, Time elseValue) {
71+
return Checker.isNull(date) ? elseValue : new Time(date.getTime());
72+
}
73+
2074
/**
2175
* 第一个值是否大于第二个值
2276
*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy