package com.github.gfx.static_gson;

import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import com.github.gfx.static_gson.annotation.JsonSerializable;

import org.junit.Before;
import org.junit.Test;

import java.util.Date;

import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.core.Is.is;

public class DateFormatTest {

    @JsonSerializable(fieldNamingPolicy = FieldNamingPolicy.UPPER_CAMEL_CASE)
    static class Full {

        Date date;
    }

    Gson gson;

    @Before
    public void setUp() throws Exception {
        gson = new GsonBuilder()
                .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
                .registerTypeAdapterFactory(StaticGsonTypeAdapterFactory.newInstance())
                .create();
    }


    @Test
    public void testSerializeDate() throws Exception {
        long t = 1458049044439L;
        Full model = new Full();
        model.date = new Date(t);
        assertThat(gson.toJson(model), is("{\"Date\":\"2016-03-15T22:37:24+0900\"}"));
    }
}

@@ -273,16 +273,43 @@
 il.Date;
+%0Aimport java.util.TimeZone;
 %0A%0Aimport
@@ -609,32 +609,120 @@
 ows Exception %7B%0A
+        System.setProperty(%22user.timezone%22, %22UTC%22);%0A        TimeZone.setDefault(null);%0A%0A
         gson = n
@@ -917,17 +917,16 @@
 %0A    %7D%0A%0A
-%0A
     @Tes
@@ -1152,18 +1152,18 @@
 -15T
-22
+13
 :37:24+0
 900%5C
@@ -1158,17 +1158,17 @@
 :37:24+0
-9
+0
 00%5C%22%7D%22))

fix tests