Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any Date/Time DSL utils in Scala?

I need to manipulate and calculate lots of things related to date, such as "is today?", "is before yesterday?", "now plus 3 days" etc. Is there any library or dsl in scala that can help with that? I was hoping for something with implicit conversions.

I will be using it with lift snippets, so Lift helpers works too. I saw that TimeHelpers in lift has some methods, that's a good start but I am looking for something more.

like image 842
Johnny Everson Avatar asked Jan 11 '12 00:01

Johnny Everson


People also ask

What is Scala DSL?

A Domain-Specific Language is a programming language that mimics the terms, idioms, and expressions used among experts in the targeted domain. Code written in a DSL reads like structured prose for the domain.

How do I get the current time in Scala?

You can get the current time using the hour formatting over the calendar method variable. The Java functions calendar() and SimpleDateFormat() are valid in Scala also.

Is there a date type in Scala?

Definition of Scala Date Function. In scala we do not have any date-time library or function available, we can use java data time, calendar, Date library to deal with dates in Scala. By using these functions, we can convert our date to a string and vice versa, also we can format our date.


2 Answers

You can use the following scala wrapper for joda-time.

Scala-time

like image 170
Neil Essy Avatar answered Sep 25 '22 01:09

Neil Essy


If you have to manipulate java.util.Date, there is also Moments

like image 38
Eugene Ryzhikov Avatar answered Sep 22 '22 01:09

Eugene Ryzhikov