Skip to content

Instantly share code, notes, and snippets.

@userddssilva
Created April 9, 2021 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save userddssilva/70c7c2e3a7f297df81a58254f29f4572 to your computer and use it in GitHub Desktop.
Save userddssilva/70c7c2e3a7f297df81a58254f29f4572 to your computer and use it in GitHub Desktop.
fun convertLongToTime(time: Long): String {
val date = Date(time)
val format = SimpleDateFormat("yyyy.MM.dd HH:mm")
return format.format(date)
}
fun currentTimeToLong(): Long {
return System.currentTimeMillis()
}
fun convertDateToLong(date: String): Long {
val df = SimpleDateFormat("yyyy.MM.dd HH:mm")
return df.parse(date).time
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment