This project has retired. For details please refer to its
Attic page.
Util xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.chukwa.extraction.demux.processor;
20
21
22 import java.text.SimpleDateFormat;
23 import java.util.Calendar;
24
25 public class Util {
26 static SimpleDateFormat day = new java.text.SimpleDateFormat("yyyyMMdd");
27
28 static Calendar calendar = Calendar.getInstance();
29 static int currentDay = 0;
30 static int currentHour = 0;
31
32 static {
33 synchronized (calendar) {
34 calendar.setTimeInMillis(System.currentTimeMillis());
35 currentDay = Integer.parseInt(day.format(calendar.getTime()));
36 currentHour = calendar.get(Calendar.HOUR_OF_DAY);
37 }
38 }
39
40 public static String generateTimeOutput(long timestamp) {
41 int workingDay = 0;
42 int workingHour = 0;
43
44 String output = null;
45
46 int minutes = 0;
47 synchronized (calendar) {
48 calendar.setTimeInMillis(timestamp);
49 workingDay = Integer.parseInt(day.format(calendar.getTime()));
50 workingHour = calendar.get(Calendar.HOUR_OF_DAY);
51 minutes = calendar.get(Calendar.MINUTE);
52 }
53
54 if (workingDay != currentDay) {
55 output = "_" + workingDay + ".D.evt";
56 } else {
57 if (workingHour != currentHour) {
58 output = "_" + workingDay + "_" + workingHour + ".H.evt";
59 } else {
60 output = "_" + workingDay + "_" + workingHour + "_";
61 int dec = minutes / 10;
62 output += dec;
63
64 int m = minutes - (dec * 10);
65 if (m < 5) {
66 output += "0.R.evt";
67 } else {
68 output += "5.R.evt";
69 }
70 }
71 }
72
73 return output;
74 }
75 }