【kotlin】long转化为date类型 或者date字符串

1.方法体中的

package org.joda.time.DateTime(long类型)
fun Long?.toDateTime() = if (null != this) DateTime(this) else null

2.再一个方法

private fun dateTime(
            time:Long? = null
    ) = if(time != null) time?.toDateTime().toString() else ""

3.直接调用 上面的方法即可实现转化

dateTime(Long?类型的字段)
原文地址:https://www.cnblogs.com/sxdcgaq8080/p/8677458.html