strftime is an implementation of the strftime standard C function for the Scala programming language.
The following example program shows how to use the convenience functions to write the current time (when this readme was written), a java.time.LocalDate
object and a java.time.LocalDateTime
.
import java.time.{LocalDate, LocalDateTime, OffsetDateTime}
import xyz.hyperreal.strftime.Strftime
object Main extends App {
println( Strftime.format("%Y-%m-%d %H:%M") )
println( Strftime.format("%b %d, %y", LocalDate.parse("2016-03-14")) )
println( Strftime.format("%a, %b %d, %y at %R", LocalDateTime.parse("2016-03-14T10:47")) )
println( Strftime.format("%a, %d %b %Y %T %z", OffsetDateTime.parse("2018-05-09T13:09:49.721-04:00")) )
println( LocalDateTime.parse("Wednesday, May 9, 2018 1:09:49 PM", Strftime.convert("%c")) )
}
This program printed
2018-04-20 12:12
Mar 14, 16
Mon, Mar 14, 16 at 10:47
Wed, 09 May 2018 13:09:49 -0400
2018-05-09T13:09:49
Use the following definition to use strftime in your Maven project:
<repository>
<id>hyperreal</id>
<url>https://dl.bintray.com/edadma/maven</url>
</repository>
<dependency>
<groupId>xyz.hyperreal</groupId>
<artifactId>strftime</artifactId>
<version>0.2.3</version>
</dependency>
Add the following to your build.sbt
file to use strftime in your SBT project:
resolvers += "Hyperreal Repository" at "https://dl.bintray.com/edadma/maven"
libraryDependencies += "xyz.hyperreal" %% "strftime" % "0.2.3"
- Java 8
- SBT 1.1.4+
- Scala 2.12.5+
git clone git://github.com/edadma/strftime.git
cd strftime
sbt test
ISC © 2018 Edward Maxedon