In this article, I would like to share some tips of Date
class in Java.
🚌 Basic knowledge for Date Class in Java
- Except a DB access part, use
java.time.LocalDateTime
orjava.time.LocalDate
.java.util.Date
is NG. - In a DB access part, use
java.sql.Timestamp
exceptionally.
Example Code for Spring and Kotlin
private val rowMapper: RowMapper |
🍣 Pattern to parse date string
Pattern to parse date string 2013-03-13T20:59:31+0000
is yyyy-MM-dd'T'HH:mm:ssZ
.
|
HH
: 24-hour time notationhh
: 12-hour time notation
🐮 Convert unixtime to Date
Converting Unixtime into Date Object is as follows:
Date time = new Date((long) timeStamp * 1000); |
🤔 Special Thanks
- https://stackoverflow.com/questions/3371326/java-date-from-unix-timestamp
- https://stackoverflow.com/questions/15433377/how-parse-2013-03-13t2059310000-date-string-to-date
🖥 Recommended VPS Service
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!