score:13
if you don't want to even construct a date object you could simply use this:
new java.sql.timestamp(system.currenttimemillis())
i would think this would be a tiny bit more efficient than using a new date(). but if you already have a date object you want to get the date from this will work for you.
new java.sql.timestamp(data.gettime())
score:16
why not something as simple as using date.gettime()
?
new java.sql.timestamp(date.gettime)
you don't need joda time for this. scala isn't really relevant here, unless you need an implicit conversion:
//import once, use everywhere
implicit def date2timestamp(date: java.util.date) =
new java.sql.timestamp(date.gettime)
val date = new java.util.date
//conversion happens implicitly
val timestamp: java.sql.timestamp = date
Source: stackoverflow.com
Related Query
- Convert Date to Timestamp in Scala
- Convert the date string with timezone column to timestamp in spark scala
- How to convert excel date long type to timestamp in scala
- Scala - How to convert a Date String to a timestamp in a Spark SQL query?
- How to convert unix timestamp to date in Spark
- Convert string to timestamp for Spark using Scala
- Convert current time in milliseconds to Date Time format in Scala
- Spark dataframe convert integer to timestamp and find date difference
- Convert date format in Scala
- How to pick up the earliest timestamp date from the RDD in scala
- Scala Spark : Convert Double Column to Date Time Column in dataframe
- Order By Timestamp is not working for Date time column in Scala Spark
- Scala - Convert a string to a timestamp
- Scala - how to convert date to integer
- Scala Unix Timestamp to Date
- How to convert from decimal to date in scala select?
- Problems to convert date to timestamp, Spark date to timestamp from unix_timestamp return null
- compare the timestamp with a specific date in Spark and Scala
- Scala - convert ISO 8601 formated string with timezone to timestamp
- Scala convert a DateTime value to Timestamp
- convert date to integer scala spark
- Convert Date From String To Datetime in spark scala
- Convert date to another format Scala Spark
- Spark Scala creating timestamp column from date
- how to convert 1 Column that is struct<year:int,month:int,day:int> to a normalized yyyy/MM/dd date datatype format in scala
- Convert microseconds string to date in Java or Scala
- spark scala split timestamp column in date column and time column
- Scala Spark convert date to a specific format
- How do I convert unix epoch nanoseconds to date only (without time) on Scala LocalDateTime
- how to convert date to yy-mm-dd in scala
More Query from same tag
- Spark/Scala transform fails in FindBugs
- scala: mapping future of tuple
- ArrayStack Remove method?
- How to use combineByKey?
- Applicative instance for Reader monad
- How to Escape Semicolon in Sql
- What is the actual class (not abstract and not trait) for Map and Set?
- "not a legal formal parameter"
- Shopify verify webhook call in Scala
- Kamon JVM and OS Metrics in docker-grafana-graphite
- DataFrame filter on date
- Sleep in future blocking thread causes RejectedExecutionException
- How to implement usage site variance in implicits?
- Simple stringLiteral matching fails when using JavaTokenParsers in Scala
- IDEA cannot find package
- netbeans java mobile application and scala application
- Scala Bounds Intersection
- Fixed Point Arithmetic in Chisel HDL
- Error While Running spark on Eclipse
- scala change log4j.property output folder based on environment
- How to define an impicit conversion from one to another existing type in Scala?
- regex split text with delimiter but don't split when the delimiter is in between ()
- Calling the overriden method from a trait with selftype
- Where are Typesafe Activator downloaded files and where is Scala installed? Macbook OSX
- runcommand is not a memeber of casbah mongocolection
- Scala source code metrics tool (lines of code, lines of comments and so on)
- Not parsing an hour from a joda DateTime
- Build.scala, % and %% symbols meaning
- Scala: Filtering collection based on type parameter
- Get the Unicode when an emoji is provided as input using scala