• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 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 
17 package libcore.libcore.icu;
18 
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assume.assumeNoException;
21 
22 import libcore.icu.DateIntervalFormat;
23 
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.junit.runners.JUnit4;
27 
28 @RunWith(JUnit4.class)
29 public class DateIntervalFormatTest {
30     private static final long MINUTE = 60 * 1000;
31     private static final long HOUR = 60 * MINUTE;
32     private static final long DAY = 24 * HOUR;
33 
34     private static final int FORMAT_SHOW_TIME = 0x00001;
35 
36     @Test
testFormatDateRange()37     public void testFormatDateRange() {
38         try {
39             Class.forName("android.text.format.DateIntervalFormat");
40         } catch (ClassNotFoundException e) {
41             // JUnit should ignore this test, instead of failing the test.
42             // It happens when the boot class path has frameworks.jar.
43             assumeNoException(e);
44         }
45 
46         String olsonId = "America/Los_Angeles";
47         String result = DateIntervalFormat.formatDateRange(0, DAY, FORMAT_SHOW_TIME, olsonId);
48 
49         // We can't assert the value because it's using the default locale, which could varies
50         // on different devices.
51         assertNotNull(result);
52     }
53 }
54