An open API service indexing awesome lists of open source software.

https://github.com/pathikrit/stamp

Scala library to format dates and times based on human-friendly examples
https://github.com/pathikrit/stamp

Last synced: over 1 year ago
JSON representation

Scala library to format dates and times based on human-friendly examples

Awesome Lists containing this project

README

          

stamp [![Circle CI](https://img.shields.io/circleci/project/pathikrit/stamp.svg)](https://circleci.com/gh/pathikrit/stamp) [![Download](https://api.bintray.com/packages/pathikrit/maven/stamp/images/download.svg)](https://bintray.com/pathikrit/maven/stamp/_latestVersion)
--------

Because life is too short to grok [Java's DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html):
```scala
import com.github.pathikrit.stamp._

val pattern: String = FormatLike("Feb 05, 2014")
assert(pattern == "MMM DD, YYYY")
```

You can then use the pattern as:
```scala
import java.time.LocalDateTime, java.time.format.DateTimeFormatter

val formatter = DateTimeFormatter.ofPattern(pattern)
println(LocalDateTime.now().format(formatter))
```

[See the tests for more examples](src/test/scala/com/github/pathikrit/stamp/FormatLikeSpec.scala)

See also: [ScalaVerbalExpressions](https://github.com/pathikrit/ScalaVerbalExpressions) - a library for writing self-documenting regex.