package com.alibaba.json.bvt.issue_2100;

import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;

import java.util.Locale;
import java.util.TimeZone;

public class Issue2156 extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;
    }

    public void test_for_issue() throws Exception {
        java.sql.Date date = java.sql.Date.valueOf("2018-07-15");
        String str = JSON.toJSONStringWithDateFormat(date, JSON.DEFFAULT_DATE_FORMAT);
        assertEquals("\"2018-07-15\"", str);
    }

    public void test_for_issue_time() throws Exception {
        java.sql.Time date = java.sql.Time.valueOf("12:13:14");
        String str = JSON.toJSONStringWithDateFormat(date, JSON.DEFFAULT_DATE_FORMAT);
        assertEquals("\"12:13:14\"", str);
    }
}

@@ -103,16 +103,51 @@
 tCase;%0A%0A
+import java.text.SimpleDateFormat;%0A
 import j
@@ -443,32 +443,916 @@
 ows Exception %7B%0A
+        SimpleDateFormat sf = new SimpleDateFormat(%22yyyy-MM-dd%22);%0A        sf.setTimeZone(JSON.defaultTimeZone);%0A        java.sql.Date date = new java.sql.Date(sf.parse(%222018-07-15%22).getTime());%0A        String str = JSON.toJSONStringWithDateFormat(date, JSON.DEFFAULT_DATE_FORMAT);%0A        assertEquals(%22%5C%222018-07-15%5C%22%22, str);%0A    %7D%0A%0A    public void test_for_issue1() throws Exception %7B%0A        SimpleDateFormat sf = new SimpleDateFormat(%22yyyy-MM-dd%22);%0A        sf.setTimeZone(JSON.defaultTimeZone);%0A        java.sql.Date date = new java.sql.Date(sf.parse(%222018-07-15%22).getTime());%0A        String str = JSON.toJSONStringWithDateFormat(date, JSON.DEFFAULT_DATE_FORMAT);%0A        assertEquals(%22%5C%222018-07-15%5C%22%22, str);%0A    %7D%0A%0A    public void test_for_issue2() throws Exception %7B%0A        SimpleDateFormat sf = new SimpleDateFormat(%22yyyy-MM-dd%22);%0A        sf.setTimeZone(JSON.defaultTimeZone);%0A
         java.sql

add testcase