common-plugin / com.cognifide.gradle.common.utils / Formats

Formats

object Formats

Functions

asHtml

fun asHtml(value: String): Document!
fun asHtml(input: InputStream): Document!

asJson

fun asJson(input: InputStream): DocumentContext!
fun asJson(value: String): DocumentContext!

asVersion

fun asVersion(value: String, partsTaken: Int = 3): GradleVersion

asXml

fun asXml(value: String): Document!
fun asXml(input: InputStream): Document!

date

fun date(date: Date = Date()): String

dateAt

fun dateAt(timestamp: Long, zoneId: ZoneId): Date

dateFileName

fun dateFileName(date: Date = Date()): String

duration

fun duration(millis: Long): String

durationFit

fun durationFit(thenMillis: Long, thenZoneId: ZoneId, durationMillis: Long): Boolean

durationSince

fun durationSince(millis: Long): String

fileSize

fun fileSize(file: File): String

fileSizeBytesToHuman

fun fileSizeBytesToHuman(bytes: Long): String

fromJson

fun <T : Any> fromJson(json: String): T
fun <T> fromJson(input: InputStream, clazz: Class<T>): T
fun <T> fromJson(json: String, clazz: Class<T>): T

fromJsonToMap

fun fromJsonToMap(json: String): Map<String, Any?>

localDateTimeAt

fun localDateTimeAt(timestamp: Long, zoneId: ZoneId): LocalDateTime

normalizePath

fun normalizePath(path: String): String

percent

fun percent(current: Int, total: Int): String
fun percent(current: Long, total: Long): String

percentExplained

fun percentExplained(current: Int, total: Int): String
fun percentExplained(current: Long, total: Long): String

projectPath

fun projectPath(file: File, project: Project): String
fun projectPath(path: String, project: Project): String

relativePath

fun relativePath(path: String, basePath: String): String

rootProjectPath

fun rootProjectPath(file: File, project: Project): String
fun rootProjectPath(path: String, project: Project): String

toBase64

fun toBase64(value: String): String

toJson

fun toJson(value: Any, pretty: Boolean = true): String
fun toJson(value: Map<String, Any?>, pretty: Boolean = true): String

toList

fun toList(value: String?, delimiter: String = ","): List<String>?

toMap

fun toMap(value: String?, valueDelimiter: String = ",", keyDelimiter: String = "="): Map<String, String>?

toMd5

fun toMd5(text: String): String

toPassword

fun toPassword(value: String): String

versionAtLeast

fun versionAtLeast(actual: String, required: String): Boolean

versionUnknown

fun versionUnknown(): GradleVersion!