package com.cronutils.mapper.format;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
/*
 * Copyright 2015 jmrozanec
 * Licensed 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.
 */
public class DateTimeFormatBuilderTest {

    @Test
    public void testCreatePatternFor() throws Exception {
        assertForPattern("MMMM dd, YYYY", "June 9, 2011");
        assertForPattern("MMM dd, YYYY", "Jun 9, 2011");
        assertForPattern("MMM dd", "Jun 09");
        assertForPattern("EEEE, MMMM dd, YYYY", "Thursday, June 9, 2011");
        assertForPattern("EEE MMM dd", "Thu Jun 9");
        assertForPattern("MM/dd/YY", "06/09/11");
        assertForPattern("hh:mm:ss a", "01:00:00 AM");
        assertForPattern("HH:mm", "20:52");
        assertForPattern("HH:mm:ss", "01:00:00");
        assertForPattern("HH:mm Z", "01:00 America/Los_Angeles");
    }

    private void assertForPattern(String dateTimePattern, String readablePattern){
        DateTime now = DateTime.now();
        assertEquals(
                DateTimeFormat.forPattern(dateTimePattern).print(now),
                new DateTimeFormatBuilder().createPatternFor(readablePattern).print(DateTime.now())
        );
    }
}
@@ -892,25 +892,24 @@
 ttern(%22MMMM 
-d
 d, YYYY%22, %22J
@@ -949,25 +949,24 @@
 attern(%22MMM 
-d
 d, YYYY%22, %22J
@@ -1062,17 +1062,16 @@
 E, MMMM 
-d
 d, YYYY%22
@@ -1129,25 +1129,24 @@
 rn(%22EEE MMM 
-d
 d%22, %22Thu Jun

Fix bad test at DateTimeFormatBuilderTest