From 50f01e1cf5e1aa625abaaf34d85be47e60075740 Mon Sep 17 00:00:00 2001 From: Winston Li Date: Fri, 5 Dec 2014 00:39:48 +0000 Subject: [PATCH] Setting time properly. --- .../wlgitbridge/writelatex/model/Snapshot.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/Snapshot.java b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/Snapshot.java index f616425036..067f862964 100644 --- a/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/Snapshot.java +++ b/services/git-bridge/src/uk/ac/ic/wlgitbridge/writelatex/model/Snapshot.java @@ -6,9 +6,9 @@ import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile; import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.SnapshotInfo; import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.WLUser; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; /** * Created by Winston on 03/11/14. @@ -30,7 +30,16 @@ public class Snapshot implements Comparable { WLUser user = info.getUser(); userName = user.getName(); userEmail = user.getEmail(); - createdAt = new Date(); + TimeZone tz = TimeZone.getDefault(); + Calendar cal = Calendar.getInstance(tz); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + sdf.setCalendar(cal); + try { + cal.setTime(sdf.parse(info.getCreatedAt())); + } catch (ParseException e) { + throw new RuntimeException(e); + } + createdAt = cal.getTime(); srcs = data.getSrcs(); atts = data.getAtts();