Questions tagged [nscala-time]
13 questions
44
votes
7 answers
How to convert unix timestamp to date in Spark
I have a data frame with a column of unix timestamp(eg.1435655706000), and I want to convert it to data with format 'yyyy-MM-DD', I've tried nscala-time but it doesn't work.
val time_col = sqlc.sql("select ts from…

youngchampion
- 599
- 1
- 4
- 5
17
votes
2 answers
Scala get current-time millis with nscala-time
I am trying to get the current time in millis doing this
DateTime.now.millis
but I get
Property[millisOfSecond]
Which is the way to get the current time in millis with nscala-time?
I want to do this, using the same library

agusgambina
- 6,229
- 14
- 54
- 94
14
votes
7 answers
Iterate over dates range (the scala way)
Given a start and an end date I would like to iterate on it by day using a foreach, map or similar function. Something like
(DateTime.now to DateTime.now + 5.day by 1.day).foreach(println)
I am using https://github.com/nscala-time/nscala-time, but…

Gismo Ranas
- 6,043
- 3
- 27
- 39
2
votes
1 answer
How to add a new column with day of week based on another in dataframe?
I have a field in a data frame currently formatted as a string (mm/dd/yyyy) and I want to create a new column in that data frame with the day of week name (i.e. Thursday) for that field. I've imported
import…

salvyp
- 23
- 1
- 4
1
vote
1 answer
Scala datetime between nscala-time and Java 8 data time
If before Java 8 releases, definitely I will choose nscala-time for my scala play project.
However since Java 8 releases, recommending using Java 8 data and time instead of joda time for Java project.
So how about for Scala project? Should we stick…

ttt
- 3,934
- 8
- 46
- 85
1
vote
1 answer
How does DateTime.now.hour(0) get a new DateTime in nscala-time?
I use nsacala-time package from https://github.com/nscala-time/nscala-time.
import com.github.nscala_time.time.Imports._
DateTime.now.hour(0)
res0: org.joda.time.DateTime = 2015-06-11T22:33:52.266+08:00
will get a new DateTime object.
But in the…

Renkai
- 1,991
- 2
- 13
- 18
0
votes
1 answer
Slick filter nscala-time DateTime by greaterEqual or smallerEqual
I am trying to filter nscala-time DateTime with Slick
package models.repositories.tables
import java.sql.Timestamp
import com.github.nscala_time.time.Imports._
import models.entities.User
import slick.lifted.ProvenShape
import…

agusgambina
- 6,229
- 14
- 54
- 94
0
votes
2 answers
How to calculate time difference with nscala_time in Spark
I'm trying to calculate the time difference of T1 and T2.
My code in spark-shell is as follow:
scala> import com.github.nscala_time.time.Imports._
import com.github.nscala_time.time.Imports._
scala> import org.joda.time.DateTime
import…

Liaoxiaochen
- 139
- 2
- 11
0
votes
1 answer
Playframework scala reading a json date with RFC1123_PATTERN to nscala DateTime
I am trying to read a date that is in a json object with an specific format of a third party API, for simplicity I will be as as I can. This is the Date
"date_created" -> "Mon, 19 Oct 2015 07:07:03 +0000",
I am trying to parse the json to a custom…

agusgambina
- 6,229
- 14
- 54
- 94
0
votes
1 answer
Get a DateTime with an specific pattern with nscala-time
I am trying to get this pattern 'dd-MM-yyyy' with a variable of type DateTime
@{DateTimeFormat.forPattern("dd-MM-YYYY").parseDateTime(user.birthday.toString)}
But I am getting this error
java.lang.IllegalArgumentException: Invalid format:…

agusgambina
- 6,229
- 14
- 54
- 94
0
votes
1 answer
Convert nscala-time Datetime to java.util.Date
I am trying to cast com.github.nscala_time.time.Imports.DateTime from nscala-time (a wrapper of joda-time) to java.util.Date
activeUntil.toDate()
But I get this error
value toDate is not a member of…

agusgambina
- 6,229
- 14
- 54
- 94
0
votes
1 answer
How can I use nscala_time inside spark-shell?
I'm trying to test some code out in the spark-shell and I need to set some time fields. We're using nscala_time for DateTime functionality. When I run
$ scala -cp `ls -1 | tr "\\n" ":"`
from the directory with my staged jars, everything works fine…

Alexander Kahoun
- 2,458
- 24
- 36
-1
votes
2 answers
extends Super in com.github.nscala_time.time.DurationBuilder
I recently downloaded source code of com.github.nscala_time package version 2.11,
After set up dependency in Maven, I got lots of errors, I checked one file
com.github.nscala_time.time.DurationBuilder, it got a line like:
class DurationBuilder(val…

James
- 89
- 1
- 1
- 4