Popularity
2.3
Declining
Activity
0.0
Stable
23
5
5

Programming language: Kotlin
License: Apache License 2.0
Tags: Misc    

KtUnits alternatives and similar libraries

Based on the "Misc" category.
Alternatively, view KtUnits alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of KtUnits or a related project?

Add another 'Misc' Library

README

Build Status Download

KtUnits

Simple unit conversion library for Kotlin.

Usage

Conversion

You can convert units easily:

fun foo() {
  val m = 100.minutes.toMilliseconds // magic
  println("100 minutes equal $m milliseconds")
}

Parameters

You can take a value as an argument without worrying about the units, and convert to the units you want when you use it.

fun wait(time: TimeValue) {
  Thread.sleep(time.toMilliseconds)
}

fun bar() {
  wait(5.seconds)
  wait(10.days)
}

Supported units

The library currently supports time (from nanoseconds to days) and memory (from bits to pebibytes).

Download

Just put this in your build.gradle or Build.kt. Replace <version> with the version shown in the badge at the top of this README.md.

dependencies {
  compile("me.sargunvohra.lib:ktunits:1.1.2")
}