37
37
package ldbc .socialnet .dbgen .generator ;
38
38
39
39
40
- import java .util .Calendar ;
41
- import java .util .Date ;
42
- import java .util .GregorianCalendar ;
43
- import java .util .Random ;
40
+ import java .text .SimpleDateFormat ;
41
+ import java .util .*;
44
42
45
43
import ldbc .socialnet .dbgen .objects .ReducedUserProfile ;
46
44
@@ -97,7 +95,7 @@ public Long randomDateInMillis( Random random )
97
95
*/
98
96
public static String formatDate (GregorianCalendar c )
99
97
{
100
- int day = c .get (Calendar .DAY_OF_MONTH );
98
+ /* int day = c.get(Calendar.DAY_OF_MONTH);
101
99
int month = c.get(Calendar.MONTH)+1; // +1 because month can be 0
102
100
int year = c.get(Calendar.YEAR);
103
101
@@ -111,6 +109,11 @@ public static String formatDate(GregorianCalendar c)
111
109
prefixMonth = "0";
112
110
113
111
return year+"-"+prefixMonth+month+"-"+prefixDay+day;
112
+ */
113
+
114
+ c .setTimeZone (TimeZone .getTimeZone ("GMT" ));
115
+ SimpleDateFormat gmtDateFormatter = new SimpleDateFormat ("yyyy-MM-dd" );
116
+ return gmtDateFormatter .format (c .getTime ());
114
117
}
115
118
116
119
public static String formatYear (GregorianCalendar c )
@@ -124,7 +127,7 @@ public static String formatYear(GregorianCalendar c)
124
127
*/
125
128
public static String formatDateDetail (GregorianCalendar c )
126
129
{
127
- int day = c .get (Calendar .DAY_OF_MONTH );
130
+ /* int day = c.get(Calendar.DAY_OF_MONTH);
128
131
int month = c.get(Calendar.MONTH)+1;
129
132
int year = c.get(Calendar.YEAR);
130
133
@@ -155,6 +158,10 @@ public static String formatDateDetail(GregorianCalendar c)
155
158
156
159
return year+"-"+prefixMonth+month+"-"+prefixDay+day +"T"
157
160
+prefixHour+hour+":"+prefixMinute+minute+":"+prefixSecond+second+"Z";
161
+ */
162
+ c .setTimeZone (TimeZone .getTimeZone ("GMT" ));
163
+ SimpleDateFormat gmtDateFormatter = new SimpleDateFormat ("yyyy-MM-ddHH:mm:ssZ" );
164
+ return gmtDateFormatter .format (c .getTime ());
158
165
}
159
166
160
167
/*
0 commit comments