Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.empgo
- import org.joda.time.{DateTime, DateTimeZone}
- import org.joda.time.format._
- object test {
- def main(args: Array[String]): Unit = {
- //时间戳转时间 获取月 日
- val tm = 1502036122000L
- val dateTime = new DateTime(tm)
- println(dateTime.getMonthOfYear +"=======" + dateTime.getDayOfMonth)
- //获取时间字符串格式
- val dateString = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").print(dateTime)
- val datezoneString = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")
- .print(dateTime.withZone(DateTimeZone.UTC))
- println(dateString)
- println(datezoneString)
- //ISO8601时间
- val dt = ISODateTimeFormat.dateTimeNoMillis().print(dateTime)
- //ISO8601 UTC
- val dtzone = ISODateTimeFormat.dateTimeNoMillis().print(
- dateTime.withZone(DateTimeZone.UTC))
- println(dt)
- println(dtzone)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement