11
zhouwei
2019-07-12 143f7be25ff19896e70ffc486999a64a3bc3b76f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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)
//    }
//}