mirror of https://github.com/lizongying/my-tv.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
813 B
33 lines
813 B
package com.lizongying.mytv
|
|
|
|
import android.content.res.Resources
|
|
import android.util.TypedValue
|
|
import java.text.SimpleDateFormat
|
|
import java.util.Date
|
|
import java.util.Locale
|
|
|
|
object Utils {
|
|
fun getDateFormat(format: String): String {
|
|
return SimpleDateFormat(format, Locale.CHINA).format(Date())
|
|
}
|
|
|
|
fun getDateTimestamp(): Long {
|
|
return Date().time / 1000
|
|
}
|
|
|
|
fun dpToPx(dp: Float): Int {
|
|
return TypedValue.applyDimension(
|
|
TypedValue.COMPLEX_UNIT_DIP,
|
|
dp,
|
|
Resources.getSystem().displayMetrics
|
|
).toInt()
|
|
}
|
|
|
|
fun dpToPx(dp: Int): Int {
|
|
return TypedValue.applyDimension(
|
|
TypedValue.COMPLEX_UNIT_DIP,
|
|
dp.toFloat(),
|
|
Resources.getSystem().displayMetrics
|
|
).toInt()
|
|
}
|
|
} |