package com.safeluck.aaej.api.extensions
|
import java.text.SimpleDateFormat
|
import java.util.*
|
|
/**
|
* Created by zw on 2018/6/28.
|
*/
|
inline fun now():Date {
|
return Date()
|
}
|
fun Date.format(pattern: String): String {
|
val formatter = SimpleDateFormat(pattern)
|
val date = formatter.format(this);
|
return date;
|
}
|
fun Date.formatDate(): String {
|
|
val formatter = SimpleDateFormat("yyyy-MM-dd")
|
val date = formatter.format(this);
|
return date;
|
}
|
|
fun Date.formatDateTime(): String {
|
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
val date = formatter.format(this);
|
return date;
|
}
|
|
fun Date.partOfDate(): Date {
|
return org.apache.commons.lang3.time.DateUtils.truncate(this, Calendar.DAY_OF_MONTH)
|
}
|
|
fun Date.addDays(days: Int): Date {
|
return org.apache.commons.lang3.time.DateUtils.addDays(this,days);
|
}
|
|
fun Date.addMinutes(minutes: Int): Date {
|
return org.apache.commons.lang3.time.DateUtils.addMinutes(this,minutes);
|
}
|
|
|
|
//
|
//
|
//public inline fun <T, R> with2(receiver: T, block: T.() -> R): R = receiver.block()
|
//public inline fun <T, R> with3(receiver: T, block: T.() -> R): R {
|
//
|
// return receiver.block()
|
//}
|
//
|
//public inline fun repeat(times: Int, action: (Int) -> Unit) {
|
// for (index in 0..times - 1) {
|
// action(index)
|
// }
|
//}
|