Last active
June 29, 2017 12:02
-
-
Save alwqx/765e084f23b292b4b89ccb5a21e8911f to your computer and use it in GitHub Desktop.
convert timestamp to Date or string in Scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date | |
import java.text.SimpleDateFormat | |
object TS2Date { | |
def main(args: Array[String]): Unit = { | |
val ts:BigInt = 1480665459 | |
val df:SimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd") | |
val date:String = df.format(ts.toLong) | |
//ret: String = 1970-01-18 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use the SimpleDateFormat formats available.
https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html