Commit b06928f4c160ce81db0ecd1fb30f5fd97b9947b7

Authored by Joanne ago
1 parent 8e31f0b44f
Exists in master

adding comments

Showing 1 changed file with 64 additions and 2 deletions Side-by-side Diff

app/com/piki_ds/utils/DateTimeEtc.scala View file @ b06928f
... ... @@ -5,17 +5,40 @@
5 5 * Created by jungwon on 8/17/15.
6 6 */
7 7 object DateTimeEtc {
  8 + /**
  9 + *
  10 + * @param currentTS : millisecond
  11 + */
8 12 def getDateKey(currentTS:Long) = {
9 13 val yesterdayTuple: (Long, String) = intoYesterdayMN(currentTS)
10 14 yesterdayTuple._2.replaceAll("[^0-9]", "").take(8)
11 15 }
12 16  
  17 + /**
  18 + *
  19 + * @param yr : 2016 (example)
  20 + * @param mo :3 (example)
  21 + * @param d : 15 (example)
  22 + * @param hr : 14 (example)
  23 + * @param min : 30 (example)
  24 + * @return
  25 + */
13 26 def intoTimeMillis(yr:Int, mo:Int, d:Int, hr:Int, min:Int) = {
14 27 val c = java.util.Calendar.getInstance()
15 28 c.set(yr,mo,d,hr,min,0)
16 29 c.getTimeInMillis()
17 30 }
18 31  
  32 + /**
  33 + *
  34 + * @param yr : 2016 (example)
  35 + * @param mo : 3 (example)
  36 + * @param d : 15 (example)
  37 + * @param hr : 14 (example)
  38 + * @param min : 30 (example)
  39 + * @param dType : "yyyy-MM-dd HH:mm:SS" (example)
  40 + * @return
  41 + */
19 42 def intoTimeString(yr:Int, mo:Int, d:Int, hr:Int, min:Int, dType:String): String = {
20 43 val format_date = new java.text.SimpleDateFormat(dType)
21 44 val c = java.util.Calendar.getInstance()
22 45  
... ... @@ -23,11 +46,21 @@
23 46 format_date.format(c.getTimeInMillis)
24 47 }
25 48  
  49 + /**
  50 + * 현재 ms 기준으로 오늘에 해당하는 string 값을 return
  51 + * @param timeMillis
  52 + * @return
  53 + */
26 54 def getToday(timeMillis:Long) = {
27 55 val format_date = new java.text.SimpleDateFormat("yyyy-MM-dd")
28 56 format_date.format(timeMillis)
29 57 }
30 58  
  59 + /**
  60 + * 어젯밤 자정 string값을 return
  61 + * @param nowTS
  62 + * @return
  63 + */
31 64 def intoYesterdayMN (nowTS:Long) = {
32 65 val format_date = new java.text.SimpleDateFormat("yyyy-MM-dd")
33 66 val c = java.util.Calendar.getInstance
... ... @@ -47,7 +80,14 @@
47 80 (format_date.parse(beforeNh).getTime, beforeNh)
48 81 }
49 82  
50   - def intoNDaysDT (nowDT:String, n:Int, goUP:Boolean) = {
  83 + /**
  84 + * n일 전/후 날짜(ms, string) 를 return
  85 + * @param nowDT
  86 + * @param n
  87 + * @param goUP
  88 + * @return
  89 + */
  90 + def intoNDaysDT (nowDT:String, n:Int, goUP:Boolean): (Long, String) = {
51 91 val incre = if (goUP) n else n*(-1)
52 92 val format_date = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
53 93 val c = java.util.Calendar.getInstance
... ... @@ -57,7 +97,13 @@
57 97 (format_date.parse(beforeNh).getTime, beforeNh)
58 98 }
59 99  
60   - def into24hBefore (nowTS:Long) = {
  100 + /**
  101 + * 기준 ms 기준으로 24시간 전 (ms, string)
  102 + *
  103 + * @param nowTS
  104 + * @return
  105 + */
  106 + def into24hBefore (nowTS:Long): (Long, String) = {
61 107 val format_date = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
62 108 val c = java.util.Calendar.getInstance
63 109 c.setTimeInMillis(nowTS)
... ... @@ -66,6 +112,14 @@
66 112 (format_date.parse(before24h).getTime, before24h)
67 113 }
68 114  
  115 + /**
  116 + * 날짜 리스트 만들기
  117 + * @param limit
  118 + * @param range
  119 + * @param goUp
  120 + * @param intoFormat
  121 + * @return
  122 + */
69 123 def makeDateList(limit:String, range:Int, goUp:Boolean, intoFormat:String) = {
70 124 val c = java.util.Calendar.getInstance
71 125 val format_date = new java.text.SimpleDateFormat(intoFormat)
... ... @@ -76,6 +130,14 @@
76 130 })
77 131 }
78 132  
  133 + /**
  134 + * 시간대 리스트 만들기
  135 + * @param start
  136 + * @param limit
  137 + * @param goUp
  138 + * @param intoFormat
  139 + * @return
  140 + */
79 141 def makeHourList(start:String, limit:Long, goUp:Boolean, intoFormat:String) = {
80 142 val c = java.util.Calendar.getInstance
81 143 val format_date = new java.text.SimpleDateFormat(intoFormat)