Skip to content

Commit 035e80e

Browse files
committed
Fixed issue with date timezone
1 parent d2ea1ae commit 035e80e

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/main/java/ldbc/socialnet/dbgen/generator/DateGenerator.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737
package ldbc.socialnet.dbgen.generator;
3838

3939

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.*;
4442

4543
import ldbc.socialnet.dbgen.objects.ReducedUserProfile;
4644

@@ -97,7 +95,7 @@ public Long randomDateInMillis( Random random )
9795
*/
9896
public static String formatDate(GregorianCalendar c)
9997
{
100-
int day = c.get(Calendar.DAY_OF_MONTH);
98+
/*int day = c.get(Calendar.DAY_OF_MONTH);
10199
int month = c.get(Calendar.MONTH)+1; // +1 because month can be 0
102100
int year = c.get(Calendar.YEAR);
103101
@@ -111,6 +109,11 @@ public static String formatDate(GregorianCalendar c)
111109
prefixMonth = "0";
112110
113111
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());
114117
}
115118

116119
public static String formatYear(GregorianCalendar c)
@@ -124,7 +127,7 @@ public static String formatYear(GregorianCalendar c)
124127
*/
125128
public static String formatDateDetail(GregorianCalendar c)
126129
{
127-
int day = c.get(Calendar.DAY_OF_MONTH);
130+
/* int day = c.get(Calendar.DAY_OF_MONTH);
128131
int month = c.get(Calendar.MONTH)+1;
129132
int year = c.get(Calendar.YEAR);
130133
@@ -155,6 +158,10 @@ public static String formatDateDetail(GregorianCalendar c)
155158
156159
return year+"-"+prefixMonth+month+"-"+prefixDay+day +"T"
157160
+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());
158165
}
159166

160167
/*

0 commit comments

Comments
 (0)