【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?类型的字段)

 

posted @ 2018-03-30 17:18  Angel挤一挤  阅读(740)  评论(0编辑  收藏  举报