blob: 0f08d183c14b3d030f0772ac6a64281c322b29f9 [file] [log] [blame]
Jeff Sharkey06c5f8a2012-12-04 09:53:44 -08001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.text.format;
18
Andrei Stingaceanubbe51f82017-04-28 14:48:17 +010019import static org.junit.Assert.assertFalse;
20import static org.junit.Assert.assertTrue;
21
Siyamed Sinir68089c82016-06-29 16:55:35 -070022import android.support.test.filters.SmallTest;
Andrei Stingaceanubbe51f82017-04-28 14:48:17 +010023import android.support.test.runner.AndroidJUnit4;
Jeff Sharkey06c5f8a2012-12-04 09:53:44 -080024
Andrei Stingaceanubbe51f82017-04-28 14:48:17 +010025import org.junit.Test;
26import org.junit.runner.RunWith;
Jeff Sharkey06c5f8a2012-12-04 09:53:44 -080027
Joachim Sauer20c5ef72017-06-01 11:22:26 +010028import java.util.Locale;
29
Andrei Stingaceanubbe51f82017-04-28 14:48:17 +010030@SmallTest
31@RunWith(AndroidJUnit4.class)
32public class DateFormatTest {
Siyamed Sinir68089c82016-06-29 16:55:35 -070033
Andrei Stingaceanubbe51f82017-04-28 14:48:17 +010034 @Test
35 public void testHasDesignator() {
Jeff Sharkey06c5f8a2012-12-04 09:53:44 -080036 assertTrue(DateFormat.hasDesignator("hh:mm:ss", DateFormat.MINUTE));
37 assertTrue(DateFormat.hasDesignator("myyyy", DateFormat.MINUTE));
38 assertTrue(DateFormat.hasDesignator("mmm", DateFormat.MINUTE));
39
40 assertFalse(DateFormat.hasDesignator("hh:MM:ss", DateFormat.MINUTE));
41 }
42
Andrei Stingaceanubbe51f82017-04-28 14:48:17 +010043 @Test
44 public void testHasDesignatorEscaped() {
Jeff Sharkey06c5f8a2012-12-04 09:53:44 -080045 assertTrue(DateFormat.hasDesignator("hh:mm 'LOL'", DateFormat.MINUTE));
46
47 assertFalse(DateFormat.hasDesignator("hh:mm 'yyyy'", DateFormat.YEAR));
48 }
Joachim Sauer20c5ef72017-06-01 11:22:26 +010049
50 @Test
51 public void testIs24HourLocale() {
52 assertFalse(DateFormat.is24HourLocale(Locale.US));
53 assertTrue(DateFormat.is24HourLocale(Locale.GERMANY));
54 }
Jeff Sharkey06c5f8a2012-12-04 09:53:44 -080055}