/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 * (c) 2015 - Interseroh and Crowdcode
 */
package de.interseroh.report.formatters;

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

import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;

import org.junit.Test;

/**
 * @author Ingo Düppe (Crowdcode)
 */
public class TimeFormatterTest {

    private static final Time testTime = new Time(45900000L);

    private static final TimeFormatter formatter = new TimeFormatter();

    @Test
    public void testParse_DE() throws Exception {
        Time parsed = formatter.parse("13:45", Locale.GERMAN);
        assertThat(parsed, is(testTime));
    }

    @Test
    public void testPrint_DE() throws Exception {
        String print = formatter.print(testTime, Locale.GERMAN);
        assertThat(print, is("13:45"));
    }

    @Test
    public void testPrint_US() throws Exception {
        String print = formatter.print(testTime, Locale.US);
        assertThat(print, is("1:45 PM"));
    }

    @Test
    public void testParse_US() throws Exception {
        Time parsed = formatter.parse("1:45 PM", Locale.US);
        assertThat(parsed, is(testTime));
    }

    @Test
    public void testDateFormat() throws Exception {
        DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.GERMAN);
        System.out.println(((SimpleDateFormat)dateFormat).toLocalizedPattern());
    }
}
@@ -883,101 +883,8 @@
 s;%0A%0A
-import static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.core.Is.is;%0A%0A
 impo
@@ -901,16 +901,16 @@
 l.Time;%0A
+
 import j
@@ -1015,16 +1015,109 @@
 .Test;%0A%0A
+import static org.hamcrest.MatcherAssert.assertThat;%0Aimport static org.hamcrest.core.Is.is;%0A%0A
 /**%0A * @
@@ -1188,70 +1188,8 @@
  %7B%0A%0A
-    private static final Time testTime = new Time(45900000L);%0A
 %0A   
@@ -1377,32 +1377,26 @@
 le.GERMAN);%0A
-        
+%09%09
 assertThat(p
@@ -1398,121 +1398,8 @@
 hat(
-parsed, is(testTime));%0A    %7D%0A%0A    @Test%0A    public void testPrint_DE() throws Exception %7B%0A        String print = 
 form
@@ -1406,32 +1406,30 @@
 atter.print(
-testTime
+parsed
 , Locale.GER
@@ -1436,224 +1436,25 @@
 MAN)
-;%0A        assertThat(print, is(%2213:45%22));%0A    %7D%0A%0A    @Test%0A    public void testPrint_US() throws Exception %7B%0A        String print = formatter.print(testTime, Locale.US);%0A        assertThat(print, is(%221:45 PM%22));%0A    
+, is(%2213:45%22));%0A%09
 %7D%0A%0A 
@@ -1573,24 +1573,18 @@
 le.US);%0A
-        
+%09%09
 assertTh
@@ -1590,35 +1590,61 @@
 hat(
-parsed, is(testTime));%0A    
+formatter.print(parsed, Locale.US), is(%221:45 PM%22));%0A%09
 %7D%0A%0A 

fix test