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
- Host: GitHub
- URL: https://github.com/pathikrit/stamp
- Owner: pathikrit
- Created: 2015-02-22T22:22:25.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-09T05:44:07.000Z (over 11 years ago)
- Last Synced: 2025-01-29T07:20:23.779Z (over 1 year ago)
- Language: Scala
- Homepage:
- Size: 157 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
stamp [](https://circleci.com/gh/pathikrit/stamp) [](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.