Initial Commit only include kotlinx.datetime utils, others will follow.
NOTEs:
- use .toEpochMilliseconds() to convert to Long values
- ALWAYS store dates un UCT
- for this demo I used
now()(kotlinx.datetime.Clock.System.now) for Instant
Instant.dateTimePeriod()=PT0.000324000SnowToLongSystemDefault()=1700058378780currentMoment()=2023-11-15T14:26:18.780031ZgetCurrentTimeInSeconds()=1700058378currentDayFormatted()=2023 NOVEMBER 15currentMomentUtc()=2023-11-15T14:26:18.780062ZnowToLongUtc()=1700058378780nextMonthUtc()=2023-12-01T00:00:00ZfirstDayUtc()=2023-11-01T00:00:00ZlastDayUtc()=2023-11-30T00:00:00ZdateInUtc()=2023-11-15in30DaysUtc()=2023-12-15T14:26:18.780031Zpast15DaysUtc()=2023-10-31T14:26:18.780031Zpast60DaysUtc()=2023-09-16T14:26:18.780031ZinXDaysUtc(days = 20)=2023-12-05T14:26:18.780031ZpastXDaysUtc(days = 20)=2023-10-26T14:26:18.780031ZString?.splitToStrings(delimiter: Char = ','): List<String>Inverse of KotlinList<String>.joinToString()fun <T> Gson.fromJsonOrNull(json: String, clazz: Class<T>): T?To convert json to classesfun String.isValidJson(): BooleanTo test if a json is validgetResourceProperty()get a property value from resource filesetResourceProperty()set a property value in resource file
P.S. Request more Utilities if you need.
In your root build.gradle.kts
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven("https://jitpack.io")
}
}
add the dependency
dependencies {
implementation("com.github.Morons:CryptoCodeKotlinLibrary:1.1.0")
}