This is yet another implementation of NewBase60 algorithm made for Kotlin and Java.
In a nutshell, this library will be useful if you want to implement a URL shortener, like Bitly or TinyURL, that is URL-safe and does not contain confusing character pairs, such as an uppercase letter O and 0, an uppercase letter I and 1.
Check out this article of Tantek Çelik for more information.
numberToSexagesimal(0) // "0"
numberToSexagesimal(60) // "10"
numberToSexagesimal(1337) // "NH"
numberToSexagesimal(9_223_372_036_854_775_807) // "FFD_YXvLFW7"
sexagesimalToNumber("10") // 60L
sexagesimalToNumber("NH") // 1337L
sexagesimalToNumber("NH🥺") // java.text.ParseException(errorOffset=2, detailMessage="Couldn't parse the character "🥺"")
The artifact is available on Maven Central, so just add the below dependency to your favorite build automation tool.
<dependency>
<groupId>online.senpai</groupId>
<artifactId>newbase60</artifactId>
<version>1.0.1</version>
</dependency>
implementation 'online.senpai:newbase60:1.0.1'
implementation("online.senpai:newbase60:1.0.1")