1 /* 2 ******************************************************************************* 3 * Copyright (C) 2001-2015, International Business Machines Corporation and * 4 * others. All Rights Reserved. * 5 ******************************************************************************* 6 */ 7 8 /** 9 * Port From: ICU4C v1.8.1 : format : DateIntervalFormatTest 10 * Source File: $ICU4CRoot/source/test/intltest/dtifmtts.cpp 11 **/ 12 13 package com.ibm.icu.dev.test.format; 14 15 import java.text.FieldPosition; 16 import java.text.ParseException; 17 import java.util.Date; 18 import java.util.Locale; 19 20 import com.ibm.icu.impl.Utility; 21 import com.ibm.icu.text.DateFormat; 22 import com.ibm.icu.text.DateIntervalFormat; 23 import com.ibm.icu.text.DateIntervalInfo; 24 import com.ibm.icu.text.DateIntervalInfo.PatternInfo; 25 import com.ibm.icu.text.SimpleDateFormat; 26 import com.ibm.icu.util.Calendar; 27 import com.ibm.icu.util.DateInterval; 28 import com.ibm.icu.util.TimeZone; 29 import com.ibm.icu.util.ULocale; 30 31 public class DateIntervalFormatTest extends com.ibm.icu.dev.test.TestFmwk { 32 33 /** 34 * 35 */ 36 private static final ULocale SPANISH = new ULocale("es"); 37 /** 38 * 39 */ 40 private static final ULocale LA_SPANISH = new ULocale("es-419"); 41 main(String[] args)42 public static void main(String[] args) throws Exception { 43 new DateIntervalFormatTest().run(args); 44 } 45 46 47 /** 48 * Test format 49 */ TestFormat()50 public void TestFormat() { 51 // first item is date pattern 52 // followed by a group of locale/from_data/to_data/skeleton/interval_data 53 String[] DATA = { 54 "yyyy MM dd HH:mm:ss", 55 // test root 56 "root", "2007 11 10 10:10:10", "2007 12 10 10:10:10", "yM", "2007-11 \\u2013 2007-12", 57 58 // test 'H' and 'h', using availableFormat in fallback 59 "en", "2007 11 10 10:10:10", "2007 11 10 15:10:10", "Hms", "10:10:10 \\u2013 15:10:10", 60 "en", "2007 11 10 10:10:10", "2007 11 10 15:10:10", "hms", "10:10:10 AM \\u2013 3:10:10 PM", 61 62 // test skeleton with both date and time 63 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 AM \\u2013 Nov 20, 2007, 10:10 AM", 64 65 "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "dMMMyhm", "Nov 10, 2007, 10:10 \\u2013 11:10 AM", 66 67 "en", "2007 11 10 10:10:10", "2007 11 10 11:10:10", "hms", "10:10:10 AM \\u2013 11:10:10 AM", 68 69 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10, 2007 \\u2013 Friday, October 10, 2008", 70 71 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMy", "October 10, 2007 \\u2013 October 10, 2008", 72 73 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMM", "October 10, 2007 \\u2013 October 10, 2008", 74 75 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMMy", "October 2007 \\u2013 October 2008", 76 77 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10, 2007 \\u2013 Friday, October 10, 2008", 78 79 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMMy", "Wed, Oct 10, 2007 \\u2013 Fri, Oct 10, 2008", 80 81 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMy", "Oct 10, 2007 \\u2013 Oct 10, 2008", 82 83 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "Oct 10, 2007 \\u2013 Oct 10, 2008", 84 85 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Oct 2007 \\u2013 Oct 2008", 86 87 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMMM", "Wed, Oct 10, 2007 \\u2013 Fri, Oct 10, 2008", 88 89 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", 90 91 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10/10/2007 \\u2013 10/10/2008", 92 93 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10/10/2007 \\u2013 10/10/2008", 94 95 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10/2007 \\u2013 10/2008", 96 97 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", 98 99 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10/10/2007 \\u2013 10/10/2008", 100 101 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Ed", "10 Wed \\u2013 10 Fri", 102 103 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007 \\u2013 2008", 104 105 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10/2007 \\u2013 10/2008", 106 107 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMM", "Oct 2007 \\u2013 Oct 2008", 108 109 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMM", "October 2007 \\u2013 October 2008", 110 111 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10/10/2007, 10:10 AM \\u2013 10/10/2008, 10:10 AM", 112 113 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT \\u2013 10/10/2008, 10:10 AM PT", 114 115 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT \\u2013 10/10/2008, 10:10 AM PDT", 116 117 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "h", "10/10/2007, 10 AM \\u2013 10/10/2008, 10 AM", 118 119 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hv", "10/10/2007, 10 AM PT \\u2013 10/10/2008, 10 AM PT", 120 121 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hz", "10/10/2007, 10 AM PDT \\u2013 10/10/2008, 10 AM PDT", 122 123 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", 124 125 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EddMMy", "Wed, 10/10/2007 \\u2013 Fri, 10/10/2008", 126 127 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmm", "10/10/2007, 10:10 AM \\u2013 10/10/2008, 10:10 AM", 128 129 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT \\u2013 10/10/2008, 10:10 AM PDT", 130 131 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM \\u2013 10/10/2008, 10:10:10 AM", 132 133 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMMMy", "O 10, 2007 \\u2013 O 10, 2008", 134 135 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEEdM", "W, 10/10/2007 \\u2013 F, 10/10/2008", 136 137 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMMy", "Wednesday, October 10 \\u2013 Saturday, November 10, 2007", 138 139 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "October 10 \\u2013 November 10, 2007", 140 141 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMM", "October 10 \\u2013 November 10", 142 143 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "October \\u2013 November 2007", 144 145 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMM", "Wednesday, October 10 \\u2013 Saturday, November 10", 146 147 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMMy", "Wed, Oct 10 \\u2013 Sat, Nov 10, 2007", 148 149 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMy", "Oct 10 \\u2013 Nov 10, 2007", 150 151 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "Oct 10 \\u2013 Nov 10", 152 153 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Oct \\u2013 Nov 2007", 154 155 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMMM", "Wed, Oct 10 \\u2013 Sat, Nov 10", 156 157 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Wed, 10/10/2007 \\u2013 Sat, 11/10/2007", 158 159 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMy", "10/10/2007 \\u2013 11/10/2007", 160 161 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dM", "10/10 \\u2013 11/10", 162 163 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10/2007 \\u2013 11/2007", 164 165 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdM", "Wed, 10/10 \\u2013 Sat, 11/10", 166 167 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10/10 \\u2013 11/10", 168 169 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "Ed", "10 Wed \\u2013 10 Sat", 170 171 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "y", "2007", 172 173 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "M", "10 \\u2013 11", 174 175 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Oct \\u2013 Nov", 176 177 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMM", "October \\u2013 November", 178 179 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hm", "10/10/2007, 10:10 AM \\u2013 11/10/2007, 10:10 AM", 180 181 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "10/10/2007, 10:10 AM PT \\u2013 11/10/2007, 10:10 AM PT", 182 183 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmz", "10/10/2007, 10:10 AM PDT \\u2013 11/10/2007, 10:10 AM PST", 184 185 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "h", "10/10/2007, 10 AM \\u2013 11/10/2007, 10 AM", 186 187 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hv", "10/10/2007, 10 AM PT \\u2013 11/10/2007, 10 AM PT", 188 189 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hz", "10/10/2007, 10 AM PDT \\u2013 11/10/2007, 10 AM PST", 190 191 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEddMMyyyy", "Wed, 10/10/2007 \\u2013 Sat, 11/10/2007", 192 193 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EddMMy", "Wed, 10/10/2007 \\u2013 Sat, 11/10/2007", 194 195 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hhmm", "10/10/2007, 10:10 AM \\u2013 11/10/2007, 10:10 AM", 196 197 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hhmmzz", "10/10/2007, 10:10 AM PDT \\u2013 11/10/2007, 10:10 AM PST", 198 199 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10/10/2007, 10:10:10 AM \\u2013 11/10/2007, 10:10:10 AM", 200 201 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMMy", "O 10 \\u2013 N 10, 2007", 202 203 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEEdM", "W, 10/10 \\u2013 S, 11/10", 204 205 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "Saturday, November 10 \\u2013 Tuesday, November 20, 2007", 206 207 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMy", "November 10 \\u2013 20, 2007", 208 209 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "November 10 \\u2013 20", 210 211 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMMy", "November 2007", 212 213 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "Saturday, November 10 \\u2013 Tuesday, November 20", 214 215 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMMy", "Sat, Nov 10 \\u2013 Tue, Nov 20, 2007", 216 217 218 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMM", "Nov 10 \\u2013 20", 219 220 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov 2007", 221 222 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMM", "Sat, Nov 10 \\u2013 Tue, Nov 20", 223 224 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sat, 11/10/2007 \\u2013 Tue, 11/20/2007", 225 226 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "11/10/2007 \\u2013 11/20/2007", 227 228 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 \\u2013 11/20", 229 230 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11/2007", 231 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "Sat, 11/10 \\u2013 Tue, 11/20", 232 233 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10 \\u2013 20", 234 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Ed", "10 Sat \\u2013 20 Tue", 235 236 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11", 237 238 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "Nov", 239 240 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hm", "11/10/2007, 10:10 AM \\u2013 11/20/2007, 10:10 AM", 241 242 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "11/10/2007, 10:10 AM PT \\u2013 11/20/2007, 10:10 AM PT", 243 244 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "11/10/2007, 10:10 AM PST \\u2013 11/20/2007, 10:10 AM PST", 245 246 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hz", "11/10/2007, 10 AM PST \\u2013 11/20/2007, 10 AM PST", 247 248 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEddMMyyyy", "Sat, 11/10/2007 \\u2013 Tue, 11/20/2007", 249 250 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EddMMy", "Sat, 11/10/2007 \\u2013 Tue, 11/20/2007", 251 252 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hhmm", "11/10/2007, 10:10 AM \\u2013 11/20/2007, 10:10 AM", 253 254 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hms", "11/10/2007, 10:10:10 AM \\u2013 11/20/2007, 10:10:10 AM", 255 256 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMMy", "N 10 \\u2013 20, 2007", 257 258 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEEdM", "S, 11/10 \\u2013 T, 11/20", 259 260 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "Wednesday, January 10, 2007", 261 262 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMy", "January 10, 2007", 263 264 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMM", "January 10", 265 266 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMMy", "January 2007", 267 268 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMM", "Wednesday, January 10", 269 270 271 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMy", "Jan 10, 2007", 272 273 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "Jan 10", 274 275 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan 2007", 276 277 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMMM", "Wed, Jan 10", 278 279 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdMy", "Wed, 1/10/2007", 280 281 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMy", "1/10/2007", 282 283 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dM", "1/10", 284 285 286 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EdM", "Wed, 1/10", 287 288 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "d", "10", 289 290 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Ed", "10 Wed", 291 292 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "y", "2007", 293 294 295 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMM", "Jan", 296 297 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMM", "January", 298 299 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "10:00 AM \\u2013 2:10 PM", 300 301 302 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "10:00 AM \\u2013 2:10 PM PST", 303 304 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 AM \\u2013 2 PM", 305 306 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hv", "10 AM \\u2013 2 PM PT", 307 308 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hz", "10 AM \\u2013 2 PM PST", 309 310 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEddMMyyyy", "Wed, 01/10/2007", 311 312 313 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmm", "10:00 AM \\u2013 2:10 PM", 314 315 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hhmmzz", "10:00 AM \\u2013 2:10 PM PST", 316 317 318 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMMMy", "J 10, 2007", 319 320 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEEdM", "W, 1/10", 321 322 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMMMy", "Wednesday, January 10, 2007", 323 324 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMMy", "January 10, 2007", 325 326 327 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "MMMMy", "January 2007", 328 329 330 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMMy", "Wed, Jan 10, 2007", 331 332 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMy", "Jan 10, 2007", 333 334 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMM", "Jan 10", 335 336 337 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMMM", "Wed, Jan 10", 338 339 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdMy", "Wed, 1/10/2007", 340 341 342 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dM", "1/10", 343 344 345 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EdM", "Wed, 1/10", 346 347 348 349 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "y", "2007", 350 351 352 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "MMM", "Jan", 353 354 355 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "10:00 \\u2013 10:20 AM", 356 357 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00 \\u2013 10:20 AM PT", 358 359 360 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "10 AM", 361 362 363 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 AM PST", 364 365 366 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EddMMy", "Wed, 01/10/2007", 367 368 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmm", "10:00 \\u2013 10:20 AM", 369 370 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hhmmzz", "10:00 \\u2013 10:20 AM PST", 371 372 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hms", "10:00:10 AM \\u2013 10:20:10 AM", 373 374 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMMM", "January 10", 375 376 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMM", "Wednesday, January 10", 377 378 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMMMy", "Wed, Jan 10, 2007", 379 380 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dMMM", "Jan 10", 381 382 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdMMM", "Wed, Jan 10", 383 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "dM", "1/10", 384 385 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "My", "1/2007", 386 387 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EdM", "Wed, 1/10", 388 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "d", "10", 389 390 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Ed", "10 Wed", 391 392 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "y", "2007", 393 394 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "M", "1", 395 396 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMM", "Jan", 397 398 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "MMMM", "January", 399 400 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "10:10 AM", 401 402 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 AM PT", 403 404 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 AM PST", 405 406 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "10 AM", 407 408 409 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 AM PST", 410 411 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hhmmzz", "10:10 AM PST", 412 413 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hms", "10:10:10 AM", 414 415 "en", "2007 01 01 22:00:00", "2007 01 01 23:00:00", "yMMMMdHm", "January 1, 2007, 22:00 \u2013 23:00", 416 417 "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMMy", "2007\\u5e7410\\u670810\\u65e5\\u661f\\u671f\\u4e09\\u81f32008\\u5e7410\\u670810\\u65e5\\u661f\\u671f\\u4e94", 418 419 "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "2007/10/10 \\u4e0a\\u534810:10 \\u2013 2008/10/10 \\u4e0a\\u534810:10", 420 421 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMMy", "2007\\u5e7410\\u670810\\u65e5\\u81f311\\u670810\\u65e5", 422 423 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMM", "10\\u670810\\u65e5\\u81f311\\u670810\\u65e5", 424 425 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMMy", "2007\\u5e7410\\u6708\\u81f311\\u6708", 426 427 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMM", "10\\u670810\\u65e5\\u661f\\u671f\\u4e09\\u81f311\\u670810\\u65e5\\u661f\\u671f\\u516d", 428 429 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "2007/10/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4 \\u4E0A\\u534810:10 \\u2013 2007/11/10 \\u6D1B\\u6749\\u77F6\\u65F6\\u95F4 \\u4E0A\\u534810:10", 430 431 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMMy", "2007\\u5e7411\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c", 432 433 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMMy", "2007\\u5e7411\\u670810\\u65e5\\u81f320\\u65e5", 434 435 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMM", "11\\u670810\\u65e5\\u81f320\\u65e5", 436 437 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMMy", "2007\\u5E7411\\u6708", // (fixed expected result per ticket 6872<-6626) 438 439 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMM", "11\\u670810\\u65e5\\u661f\\u671f\\u516d\\u81f320\\u65e5\\u661f\\u671f\\u4e8c", 440 441 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMMM", "11\\u670810\\u65e5\\u5468\\u516d\\u81f320\\u65e5\\u5468\\u4e8c", 442 443 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "2007/11/10\\u5468\\u516d\\u81f32007/11/20\\u5468\\u4e8c", 444 445 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "2007/11/10 \\u2013 2007/11/20", 446 447 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "11/10 \\u2013 11/20", 448 449 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "2007\u5E7411\u6708", 450 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "11/10\\u5468\\u516d\\u81f311/20\\u5468\\u4e8c", 451 452 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10\\u201320\\u65e5", 453 454 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007\\u5E74", // (fixed expected result per ticket:6626:) 455 456 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11\\u6708", 457 458 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMM", "11\\u6708", // (fixed expected result per ticket 6872<-6626 and others) 459 460 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMM", "\\u5341\\u4E00\\u6708", // (fixed expected result per ticket 6872<-6626 and others) 461 462 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmz", "2007/11/10 GMT-8 \\u4e0a\\u534810:10 \\u2013 2007/11/20 GMT-8 \\u4e0a\\u534810:10", 463 464 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "h", "2007/11/10 \\u4e0a\\u534810\\u65f6 \\u2013 2007/11/20 \\u4e0a\\u534810\\u65f6", 465 466 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMMy", "2007\\u5e741\\u670810\\u65e5\\u661f\\u671f\\u4e09", // (fixed expected result per ticket 6872<-6626) 467 468 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hm", "\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10", 469 470 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:00\\u81F3\\u4E0B\\u53482:10", 471 472 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "GMT-8\\u4e0a\\u534810:00\\u81f3\\u4e0b\\u53482:10", 473 474 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "\\u4e0a\\u534810\\u65F6\\u81f3\\u4e0b\\u53482\\u65f6", 475 476 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810\\u65F6\\u81F3\\u4E0B\\u53482\\u65F6", 477 478 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hz", "GMT-8\\u4e0a\\u534810\\u65F6\\u81f3\\u4e0b\\u53482\\u65f6", 479 480 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "dMMMM", "1\\u670810\\u65e5", // (fixed expected result per ticket 6872<-6626) 481 482 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "\\u4e0a\\u534810:00\\u81f310:20", 483 484 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "\\u6D1B\\u6749\\u77F6\\u65F6\\u95F4\\u4E0A\\u534810:00\\u81F310:20", 485 486 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "\\u4e0a\\u534810\\u65f6", 487 488 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "GMT-8\\u4e0a\\u534810\\u65f6", 489 490 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMMy", "2007\\u5e741\\u670810\\u65e5\\u661f\\u671f\\u4e09", // (fixed expected result per ticket 6872<-6626) 491 492 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "\\u4e0a\\u534810:10", 493 494 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "\\u4e0a\\u534810\\u65f6", 495 496 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. 2007 \\u2013 Freitag, 10. Okt. 2008", 497 498 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMMy", "10. Okt. 2007 \\u2013 10. Okt. 2008", 499 500 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMMM", "10. Okt. 2007 \\u2013 10. Okt. 2008", 501 502 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMMy", "Okt. 2007 \\u2013 Okt. 2008", 503 504 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EEEdMMM", "Mi., 10. Okt. 2007 \\u2013 Fr., 10. Okt. 2008", 505 506 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdMy", "Mi., 10.10.2007 \\u2013 Fr., 10.10.2008", 507 508 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dMy", "10.10.2007 \\u2013 10.10.2008", 509 510 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "dM", "10.10.2007 \\u2013 10.10.2008", 511 512 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "My", "10.2007 \\u2013 10.2008", 513 514 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "EdM", "Mi., 10.10.2007 \\u2013 Fr., 10.10.2008", 515 516 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "d", "10.10.2007 \\u2013 10.10.2008", 517 518 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "y", "2007\\u20132008", 519 520 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "M", "10.2007 \\u2013 10.2008", 521 522 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "MMM", "Okt. 2007 \\u2013 Okt. 2008", 523 524 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "hm", "10.10.2007, 10:10 vorm. \\u2013 10.10.2008, 10:10 vorm.", 525 526 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "jm", "10.10.2007, 10:10 \\u2013 10.10.2008, 10:10", 527 528 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMMy", "Mittwoch, 10. Okt. \\u2013 Samstag, 10. Nov. 2007", 529 530 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMMy", "10. Okt. \\u2013 10. Nov. 2007", 531 532 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dMMM", "10. Okt. \\u2013 10. Nov.", 533 534 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMMy", "Okt.\\u2013Nov. 2007", 535 536 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EEEEdMMM", "Mittwoch, 10. Okt. \\u2013 Samstag, 10. Nov.", 537 538 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdMy", "Mi., 10.10.2007 \\u2013 Sa., 10.11.2007", 539 540 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "dM", "10.10. \\u2013 10.11.", 541 542 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "My", "10.2007 \\u2013 11.2007", 543 544 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "EdM", "Mi., 10.10. \\u2013 Sa., 10.11.", 545 546 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "d", "10.10. \\u2013 10.11.", 547 548 549 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "M", "10.\\u201311.", 550 551 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "MMM", "Okt.\\u2013Nov.", 552 553 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hmv", "10.10.2007, 10:10 vorm. Los Angeles Zeit \\u2013 10.11.2007, 10:10 vorm. Los Angeles Zeit", 554 555 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "jmv", "10.10.2007, 10:10 Los Angeles Zeit \\u2013 10.11.2007, 10:10 Los Angeles Zeit", 556 557 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "hms", "10.10.2007, 10:10:10 vorm. \\u2013 10.11.2007, 10:10:10 vorm.", 558 559 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMMy", "Samstag, 10. \\u2013 Dienstag, 20. Nov. 2007", 560 561 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMMy", "10.\\u201320. Nov. 2007", 562 563 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMMM", "10.\\u201320. Nov.", 564 565 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "MMMy", "Nov. 2007", 566 567 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EEEEdMMM", "Samstag, 10. \\u2013 Dienstag, 20. Nov.", 568 569 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdMy", "Sa., 10.11.2007 \\u2013 Di., 20.11.2007", 570 571 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dMy", "10.11.2007 \\u2013 20.11.2007", 572 573 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "dM", "10.11. \\u2013 20.11.", 574 575 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "My", "11.2007", 576 577 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "EdM", "Sa., 10.11. \\u2013 Di., 20.11.", 578 579 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "d", "10.\\u201320.", 580 581 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "y", "2007", 582 583 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "M", "11", 584 585 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "hmv", "10.11.2007, 10:10 vorm. Los Angeles Zeit \\u2013 20.11.2007, 10:10 vorm. Los Angeles Zeit", 586 587 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "jmv", "10.11.2007, 10:10 Los Angeles Zeit \\u2013 20.11.2007, 10:10 Los Angeles Zeit", 588 589 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007", 590 591 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMMy", "10. Jan. 2007", 592 593 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "dMMM", "10. Jan.", 594 595 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "MMMy", "Jan. 2007", 596 597 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "EEEEdMMM", "Mittwoch, 10. Jan.", 598 599 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "hmz", "10:00 vorm. \\u2013 2:10 nachm. GMT-8", 600 601 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "h", "10 vorm. \\u2013 2 nachm.", 602 603 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "EEEEdMMM", "Mittwoch, 10. Jan.", 604 605 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hm", "10:00\\u201310:20 vorm.", 606 607 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmv", "10:00\\u201310:20 vorm. Los Angeles Zeit", 608 609 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hmz", "10:00\\u201310:20 vorm. GMT-8", 610 611 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "h", "10 vorm.", 612 613 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hv", "10 vorm. Los Angeles Zeit", 614 615 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "hz", "10 vorm. GMT-8", 616 617 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "EEEEdMMMy", "Mittwoch, 10. Jan. 2007", 618 619 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hm", "10:10 vorm.", 620 621 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "jm", "10:10", 622 623 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmv", "10:10 vorm. Los Angeles Zeit", 624 625 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "jmv", "10:10 Los Angeles Zeit", 626 627 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hmz", "10:10 vorm. GMT-8", 628 629 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "jmz", "10:10 GMT-8", 630 631 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "h", "10 vorm.", 632 633 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hv", "10 vorm. Los Angeles Zeit", 634 635 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "hz", "10 vorm. GMT-8", 636 637 // Thai (default calendar buddhist) 638 639 // Android patch: Force default Gregorian calendar. 640 641 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. 2550 \\u2013 \\u0E27\\u0E31\\u0E19\\u0E2D\\u0E32\\u0E17\\u0E34\\u0E15\\u0E22\\u0E4C\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. 2551", 642 643 644 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. 2550 \\u2013 10 \\u0E15.\\u0E04. 2551", 645 646 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "MMMy", "\\u0E15.\\u0E04. 2550 \\u2013 \\u0E15.\\u0E04. 2551", 647 648 649 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdMy", "\\u0E2A. 10/10/2550 \\u2013 \\u0E2D\\u0E32. 10/10/2551", 650 651 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "dMy", "10/10/2550 \\u2013 10/10/2551", 652 653 654 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "My", "10/2550 \\u2013 10/2551", 655 656 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "EdM", "\\u0E2A. 10/10/2550 \\u2013 \\u0E2D\\u0E32. 10/10/2551", 657 658 659 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "y", "2550\\u20132551", 660 661 "th", "2550 10 10 10:10:10", "2551 10 10 10:10:10", "M", "10/2550 \\u2013 10/2551", 662 663 664 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "EEEEdMMMy", "\\u0E27\\u0E31\\u0E19\\u0E40\\u0E2A\\u0E32\\u0E23\\u0E4C\\u0E17\\u0E35\\u0E48 10 \\u0E15.\\u0E04. \\u2013 \\u0E27\\u0E31\\u0E19\\u0E2D\\u0E31\\u0E07\\u0E04\\u0E32\\u0E23\\u0E17\\u0E35\\u0E48 10 \\u0E1E.\\u0E22. 2550", 665 666 667 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dMMM", "10 \\u0E15.\\u0E04. \\u2013 10 \\u0E1E.\\u0E22.", 668 669 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMMy", "\\u0E15.\\u0E04.\\u2013\\u0E1E.\\u0E22. 2550", 670 671 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "dM", "10/10 \\u2013 10/11", 672 673 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "My", "10/2550 \\u2013 11/2550", 674 675 676 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "d", "10/10 \\u2013 10/11", 677 678 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "y", "2550", 679 680 681 "th", "2550 10 10 10:10:10", "2550 11 10 10:10:10", "MMM", "\\u0E15.\\u0E04.\\u2013\\u0E1E.\\u0E22.", 682 683 // Android patch end. 684 }; 685 expect(DATA, DATA.length); 686 } 687 688 expect(String[] data, int data_length)689 private void expect(String[] data, int data_length) { 690 int i = 1; 691 while (i<data_length) { 692 String locName = data[i++]; 693 ULocale loc = new ULocale(locName); 694 SimpleDateFormat ref = new SimpleDateFormat(data[0], loc); 695 // 'f' 696 String datestr = data[i++]; 697 String datestr_2 = data[i++]; 698 Date date, date_2; 699 try { 700 date = ref.parse(datestr); 701 date_2 = ref.parse(datestr_2); 702 } catch ( ParseException e ) { 703 errln("parse exception" + e); 704 continue; 705 } 706 DateInterval dtitv = new DateInterval(date.getTime(), 707 date_2.getTime()); 708 String oneSkeleton = data[i++]; 709 DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance( 710 oneSkeleton, loc); 711 String expected = data[i++]; 712 String formatted = dtitvfmt.format(dtitv); 713 if ( !formatted.equals(Utility.unescape(expected)) ) { 714 errln("\"" + locName + "\\" + oneSkeleton + "\\" + datestr + "\\" + datestr_2 + "\"\t expected: " + expected +"\tgot: " + formatted + "\n"); 715 } 716 } 717 } 718 719 720 /* 721 * Test format using user defined DateIntervalInfo 722 */ TestFormatUserDII()723 public void TestFormatUserDII() { 724 // first item is date pattern 725 // followed by a group of locale/from_data/to_data/interval_data 726 String[] DATA = { 727 "yyyy MM dd HH:mm:ss", 728 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "Oct 10, 2007 --- Oct 10, 2008", 729 730 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 Oct 10 - Nov 2007", 731 732 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "Nov 10, 2007 --- Nov 20, 2007", 733 734 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Jan 10, 2007", 735 736 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Jan 10, 2007", 737 738 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Jan 10, 2007", 739 740 "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "2007\\u5e7410\\u670810\\u65e5 --- 2008\\u5e7410\\u670810\\u65e5", 741 742 743 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007\\u5e7411\\u670810\\u65e5 --- 2007\\u5e7411\\u670820\\u65e5", 744 745 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket 6872<-6626) 746 747 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket 6872<-6626) 748 749 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "2007\\u5e741\\u670810\\u65e5", // (fixed expected result per ticket 6872<-6626) 750 751 "de", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10. Okt. 2007 --- 10. Okt. 2008", 752 753 "de", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 Okt. 10 - Nov. 2007", 754 755 "de", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10. Nov. 2007 --- 20. Nov. 2007", 756 757 "de", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10. Jan. 2007", 758 759 "de", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10. Jan. 2007", 760 761 "de", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "10. Jan. 2007", 762 763 "es", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "10 oct. 2007 --- 10 oct. 2008", 764 765 "es", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 oct. 10 - nov. 2007", 766 767 "es", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "10 nov. 2007 --- 20 nov. 2007", 768 769 "es", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "10 ene. 2007", 770 771 "es", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "10 ene. 2007", 772 773 "es", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "10 ene. 2007", 774 }; 775 expectUserDII(DATA, DATA.length); 776 } 777 778 expectUserDII(String[] data, int data_length)779 private void expectUserDII(String[] data, int data_length) { 780 int i = 1; 781 while (i<data_length) { 782 String locName = data[i++]; 783 ULocale loc = new ULocale(locName); 784 SimpleDateFormat ref = new SimpleDateFormat(data[0], loc); 785 // 'f' 786 String datestr = data[i++]; 787 String datestr_2 = data[i++]; 788 Date date, date_2; 789 try { 790 date = ref.parse(datestr); 791 date_2 = ref.parse(datestr_2); 792 } catch ( ParseException e ) { 793 errln("parse exception" + e); 794 continue; 795 } 796 DateInterval dtitv = new DateInterval(date.getTime(), 797 date_2.getTime()); 798 799 DateIntervalInfo dtitvinf = new DateIntervalInfo(); 800 dtitvinf.setFallbackIntervalPattern("{0} --- {1}"); 801 dtitvinf.setIntervalPattern("yMMMd", Calendar.MONTH, "yyyy MMM d - MMM y"); 802 dtitvinf.setIntervalPattern("yMMMd", Calendar.HOUR_OF_DAY, "yyyy MMM d HH:mm - HH:mm"); 803 DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance( 804 DateFormat.YEAR_ABBR_MONTH_DAY, 805 loc, dtitvinf); 806 String expected = data[i++]; 807 String formatted = dtitvfmt.format(dtitv); 808 if ( !formatted.equals(Utility.unescape(expected)) ) { 809 errln("userDII: \"" + locName + "\\" + datestr + "\\" + datestr_2 + "\"\t expected: " + expected +"\tgot: " + formatted + "\n"); 810 } 811 } 812 } 813 814 815 816 /* 817 * Test format using user defined DateIntervalInfo 818 */ TestFormatCLDR()819 public void TestFormatCLDR() { 820 // first item is date pattern 821 // followed by a group of locale/from_data/to_data/interval_data 822 String[] DATA = { 823 "yyyy MM dd HH:mm:ss", 824 "en", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "all diff", 825 826 "en", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 diff Oct 10 - Nov 2007", 827 828 "en", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007 Nov 10 ~ 20", 829 830 "en", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "Jan 10, 2007", 831 832 "en", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "Jan 10, 2007", 833 834 "en", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "Jan 10, 2007", 835 836 "zh", "2007 10 10 10:10:10", "2008 10 10 10:10:10", "all diff", 837 838 "zh", "2007 10 10 10:10:10", "2007 11 10 10:10:10", "2007 diff 10\\u6708 10 - 11\\u6708 2007", 839 840 "zh", "2007 11 10 10:10:10", "2007 11 20 10:10:10", "2007 11\\u6708 10 ~ 20", 841 842 "zh", "2007 01 10 10:00:10", "2007 01 10 14:10:10", "2007\u5E741\\u670810\u65E5", // (fixed expected result per ticket 6872<-6626) 843 844 "zh", "2007 01 10 10:00:10", "2007 01 10 10:20:10", "2007\u5E741\\u670810\u65E5", // (fixed expected result per ticket 6872<-6626) 845 846 "zh", "2007 01 10 10:10:10", "2007 01 10 10:10:20", "2007\u5E741\\u670810\u65E5", // (fixed expected result per ticket 6872<-6626) 847 }; 848 expectUserCLDR(DATA, DATA.length); 849 } 850 851 expectUserCLDR(String[] data, int data_length)852 private void expectUserCLDR(String[] data, int data_length) { 853 int i = 1; 854 while (i<data_length) { 855 String locName = data[i++]; 856 ULocale loc = new ULocale(locName); 857 SimpleDateFormat ref = new SimpleDateFormat(data[0], loc); 858 // 'f' 859 String datestr = data[i++]; 860 String datestr_2 = data[i++]; 861 Date date, date_2; 862 try { 863 date = ref.parse(datestr); 864 date_2 = ref.parse(datestr_2); 865 } catch ( ParseException e ) { 866 errln("parse exception" + e); 867 continue; 868 } 869 DateInterval dtitv = new DateInterval(date.getTime(), 870 date_2.getTime()); 871 872 DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance("yyyyMMMdd", loc); 873 //DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance("yMd"); 874 //SimpleDateFormat dtfmt = new SimpleDateFormat("yyyy 'year' MMM 'month' dd 'day'", loc); 875 //dtitvfmt.setDateFormat(dtfmt); 876 DateIntervalInfo dtitvinf = new DateIntervalInfo(); 877 dtitvinf.setFallbackIntervalPattern("{0} --- {1}"); 878 dtitvinf.setIntervalPattern("yMMMd", Calendar.YEAR, "'all diff'"); 879 dtitvinf.setIntervalPattern("yMMMd", Calendar.MONTH, "yyyy 'diff' MMM d - MMM y"); 880 dtitvinf.setIntervalPattern("yMMMd", Calendar.DATE, "yyyy MMM d ~ d"); 881 dtitvinf.setIntervalPattern("yMMMd", Calendar.HOUR_OF_DAY, "yyyy MMMd HH:mm ~ HH:mm"); 882 dtitvfmt.setDateIntervalInfo(dtitvinf); 883 FieldPosition pos = new FieldPosition(0); 884 StringBuffer str = new StringBuffer(""); 885 DateFormat dtfmt = dtitvfmt.getDateFormat(); 886 Calendar fromCalendar = (Calendar) dtfmt.getCalendar().clone(); 887 Calendar toCalendar = (Calendar) dtfmt.getCalendar().clone(); 888 fromCalendar.setTimeInMillis(dtitv.getFromDate()); 889 toCalendar.setTimeInMillis(dtitv.getToDate()); 890 dtitvfmt.format(fromCalendar, toCalendar, str, pos); 891 892 String expected = data[i++]; 893 String formatted = dtitvfmt.format(dtitv).toString(); 894 if ( !formatted.equals(Utility.unescape(expected)) ) { 895 errln("CLDR: \"" + locName + "\\" + datestr + "\\" + datestr_2 + "\"\t expected: " + expected +"\tgot: " + formatted + "\n"); 896 } 897 } 898 } 899 900 901 /** 902 * Stress test 903 */ TestStress()904 public void TestStress() { 905 if (getInclusion() <= 5) { 906 logln("INFO: Skipping test"); 907 return; 908 } 909 910 // test data. 911 // The 1st is the format pattern, 912 // Next are pairs in which the 1st in the pair is the earlier date 913 // and the 2nd in the pair is the later date 914 String[] DATA = { 915 "yyyy MM dd HH:mm:ss", 916 "2007 10 10 10:10:10", "2008 10 10 10:10:10", 917 "2007 10 10 10:10:10", "2007 11 10 10:10:10", 918 "2007 11 10 10:10:10", "2007 11 20 10:10:10", 919 "2007 01 10 10:00:10", "2007 01 10 14:10:10", 920 "2007 01 10 10:00:10", "2007 01 10 10:20:10", 921 "2007 01 10 10:10:10", "2007 01 10 10:10:20", 922 }; 923 924 925 String[][] testLocale = { 926 {"en", "", ""}, 927 {"zh", "", ""}, 928 {"de", "", ""}, 929 {"ar", "", ""}, 930 {"en", "GB", ""}, 931 {"fr", "", ""}, 932 {"it", "", ""}, 933 {"nl", "", ""}, 934 {"zh", "TW", ""}, 935 {"ja", "", ""}, 936 {"pt", "BR", ""}, 937 {"ru", "", ""}, 938 {"tr", "", ""}, 939 {"es", "", ""}, 940 {"ko", "", ""}, 941 //{"th", "", ""}, 942 {"sv", "", ""}, 943 {"pl", "", ""}, 944 {"fi", "", ""}, 945 {"da", "", ""}, 946 {"pt", "PT", ""}, 947 {"ro", "", ""}, 948 {"hu", "", ""}, 949 {"he", "", ""}, 950 {"in", "", ""}, 951 {"cs", "", ""}, 952 {"el", "", ""}, 953 {"no", "", ""}, 954 {"vi", "", ""}, 955 {"bg", "", ""}, 956 {"hr", "", ""}, 957 {"lt", "", ""}, 958 {"sk", "", ""}, 959 {"sl", "", ""}, 960 {"sr", "", ""}, 961 {"ca", "", ""}, 962 {"lv", "", ""}, 963 {"uk", "", ""}, 964 {"hi", "", ""}, 965 }; 966 967 int localeIndex; 968 for ( localeIndex = 0; localeIndex < testLocale.length; ++localeIndex) { 969 stress(DATA, DATA.length, new Locale(testLocale[localeIndex][0], 970 testLocale[localeIndex][1], testLocale[localeIndex][2]), 971 testLocale[localeIndex][0]+testLocale[localeIndex][1]); 972 } 973 } 974 stress(String[] data, int data_length, Locale loc, String locName)975 private void stress(String[] data, int data_length, Locale loc, String locName) { 976 String[] skeleton = { 977 "EEEEdMMMMy", 978 "dMMMMy", 979 "dMMMM", 980 "MMMMy", 981 "EEEEdMMMM", 982 "EEEdMMMy", 983 "dMMMy", 984 "dMMM", 985 "MMMy", 986 "EEEdMMM", 987 "EEEdMy", 988 "dMy", 989 "dM", 990 "My", 991 "EEEdM", 992 "d", 993 "EEEd", 994 "y", 995 "M", 996 "MMM", 997 "MMMM", 998 "hm", 999 "hmv", 1000 "hmz", 1001 "h", 1002 "hv", 1003 "hz", 1004 "EEddMMyyyy", // following could be normalized 1005 "EddMMy", 1006 "hhmm", 1007 "hhmmzz", 1008 "hms", // following could not be normalized 1009 "dMMMMMy", 1010 "EEEEEdM", 1011 }; 1012 1013 int i = 0; 1014 1015 SimpleDateFormat ref = new SimpleDateFormat(data[i++], loc); 1016 1017 while (i<data_length) { 1018 // 'f' 1019 String datestr = data[i++]; 1020 String datestr_2 = data[i++]; 1021 Date date; 1022 Date date_2; 1023 try { 1024 date = ref.parse(datestr); 1025 date_2 = ref.parse(datestr_2); 1026 } catch ( ParseException e ) { 1027 errln("parse exception" + e); 1028 continue; 1029 } 1030 DateInterval dtitv = new DateInterval(date.getTime(), date_2.getTime()); 1031 1032 for ( int skeletonIndex = 0; 1033 skeletonIndex < skeleton.length; 1034 ++skeletonIndex ) { 1035 String oneSkeleton = skeleton[skeletonIndex]; 1036 // need special handle of "Thai" since the default calendar 1037 // of "Thai" is "Budd", not "Gregorian". 1038 DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance(oneSkeleton, loc); 1039 /* 1040 if ( locName.equals("th") ) { 1041 // reset calendar to be Gregorian 1042 GregorianCalendar gregCal = new GregorianCalendar(loc); 1043 DateFormat dformat = dtitvfmt.getDateFormat(); 1044 DateFormat newOne = (DateFormat)dformat.clone(); 1045 newOne.setCalendar(gregCal); 1046 dtitvfmt.setDateFormat(newOne); 1047 } 1048 */ 1049 dtitvfmt.format(dtitv); 1050 } 1051 1052 1053 // test interval format by algorithm 1054 for ( int style = DateFormat.FULL; style < 4; ++style ) { 1055 SimpleDateFormat dtfmt = (SimpleDateFormat) DateFormat.getDateInstance(style, loc); 1056 FieldPosition pos = new FieldPosition(0); 1057 StringBuffer str = new StringBuffer(""); 1058 Calendar fromCalendar = (Calendar) dtfmt.getCalendar().clone(); 1059 Calendar toCalendar = (Calendar) dtfmt.getCalendar().clone(); 1060 fromCalendar.setTimeInMillis(dtitv.getFromDate()); 1061 toCalendar.setTimeInMillis(dtitv.getToDate()); 1062 dtfmt.intervalFormatByAlgorithm(fromCalendar, toCalendar, str, pos); 1063 } 1064 } 1065 } 1066 1067 /* 1068 * Ticket#6396 DateIntervalInfo of ICU4J 4.0d3 throw NullPointerException 1069 */ TestT6396()1070 public void TestT6396() { 1071 DateIntervalInfo dii = new DateIntervalInfo(new ULocale("th_TH")); 1072 try { 1073 // ticket#6396 reported toString() throws NullPointerException 1074 String diiStr = dii.toString(); 1075 logln("new DateIntervalInfo(new ULocale(\"th_TH\")).toString() - " + diiStr); 1076 1077 // equals also had the similar problem 1078 DateIntervalInfo dii1 = (DateIntervalInfo)dii.clone(); 1079 if (!dii.equals(dii1)) { 1080 errln("FAIL: Cloned DateIntervalInfo is not equal to the source"); 1081 } 1082 } catch (Exception e) { 1083 errln("FAIL: Exception - " + e.getClass().getName()); 1084 } 1085 } 1086 TestConstructor()1087 public void TestConstructor() { 1088 DateIntervalInfo diiJapan = new DateIntervalInfo(ULocale.JAPAN); 1089 DateIntervalInfo diiJapanJ = new DateIntervalInfo(Locale.JAPAN); 1090 1091 assertEquals("DateIntervalInfo constructors", diiJapan, diiJapanJ); 1092 } 1093 1094 /* Tests the method 1095 * public boolean equals(Object a) 1096 */ TestDateIntervalInfoEquals()1097 public void TestDateIntervalInfoEquals(){ 1098 // Tests when "if ( a instanceof PatternInfo )" is false 1099 DateIntervalInfo diia = new DateIntervalInfo(); 1100 if(diia.equals("dummy")){ 1101 errln("DateIntervalInfo.equals(Object a) was suppose to return " + 1102 "false for a String object."); 1103 } 1104 if(diia.equals(0)){ 1105 errln("DateIntervalInfo.equals(Object a) was suppose to return " + 1106 "false for an Integer object."); 1107 } 1108 if(diia.equals(0.0)){ 1109 errln("DateIntervalInfo.equals(Object a) was suppose to return " + 1110 "false for an Integer object."); 1111 } 1112 if(diia.equals(new Object())){ 1113 errln("DateIntervalInfo.equals(Object a) was suppose to return " + 1114 "false for an Integer object."); 1115 } 1116 } 1117 1118 /* Tests the method 1119 * public Object cloneAsThawed() 1120 */ TestCloseAsThawed()1121 public void TestCloseAsThawed(){ 1122 DateIntervalInfo dii = new DateIntervalInfo(); 1123 try{ 1124 dii.cloneAsThawed(); 1125 } catch(Exception e){ 1126 errln("DateIntervalInfo.closeAsThawed() was not suppose to return " + 1127 "an exception."); 1128 } 1129 } 1130 1131 /* Tests the method 1132 * public boolean isFrozen() 1133 */ TestIsFrozen()1134 public void TestIsFrozen(){ 1135 DateIntervalInfo dii = new DateIntervalInfo(); 1136 if(dii.isFrozen() != false){ 1137 errln("DateIntervalInfo.isFrozen() is suppose to return false."); 1138 } 1139 dii.freeze(); 1140 1141 if(dii.isFrozen() != true){ 1142 errln("DateIntervalInfo.isFrozen() is suppose to return true."); 1143 } 1144 } 1145 1146 /* Tests the method 1147 * public boolean clone() 1148 */ TestClone()1149 public void TestClone(){ 1150 DateIntervalInfo dii = new DateIntervalInfo(new ULocale("en_US")); 1151 DateIntervalInfo dii_clone = (DateIntervalInfo) dii.clone(); 1152 dii_clone.freeze(); 1153 1154 // Tests when "if ( frozen )" is true 1155 if(!dii.equals(dii_clone)){ 1156 errln("DateIntervalInfo.clone() is suppose to return true for " + 1157 "an original DateIntervalInfo object and a clone of the " + 1158 "original DateIntervalInfo object."); 1159 } 1160 } 1161 1162 /* Tests the method 1163 * public void setFallbackIntervalPattern(String fallbackPattern) 1164 */ TestSetFallbackIntervalPattern()1165 public void TestSetFallbackIntervalPattern(){ 1166 DateIntervalInfo dii = new DateIntervalInfo(new ULocale("en_US")); 1167 // Tests when "if ( frozen )" is true 1168 try{ 1169 dii.freeze(); 1170 dii.setFallbackIntervalPattern(""); 1171 errln("DateIntervalInfo.setFallbackIntervalPattern(String fallbackPattern) " + 1172 "was suppose to return an exception for a frozen object."); 1173 } catch (Exception e){} 1174 1175 // Tests when "if ( firstPatternIndex == -1 || secondPatternIndex == -1 )" is true 1176 dii = (DateIntervalInfo) dii.cloneAsThawed(); 1177 try{ 1178 dii.setFallbackIntervalPattern(""); 1179 errln("DateIntervalInfo.setFallbackIntervalPattern(String fallbackPattern) " + 1180 "was suppose to return an exception for a string object of ''."); 1181 } catch(Exception e){} 1182 1183 try{ 1184 dii.setFallbackIntervalPattern("0"); 1185 errln("DateIntervalInfo.setFallbackIntervalPattern(String fallbackPattern) " + 1186 "was suppose to return an exception for a string object of 0."); 1187 } catch(Exception e){} 1188 1189 // Tests when "if ( firstPatternIndex > secondPatternIndex )" is true 1190 dii.setFallbackIntervalPattern("{1}{0}"); 1191 if(dii.getDefaultOrder() != true) 1192 errln("DateIntervalInfo.setFallbackIntervalPattern(String fallbackPattern) " + 1193 "was suppose to change the variable 'fFirstDateInPtnIsLaterDate' " + 1194 "to true."); 1195 } 1196 1197 /* Tests the method 1198 * public PatternInfo getIntervalPattern(String skeleton, int field) 1199 */ TestGetIntervalPattern()1200 public void TestGetIntervalPattern(){ 1201 // Tests when "if ( field > MINIMUM_SUPPORTED_CALENDAR_FIELD )" is true 1202 // MINIMUM_SUPPORTED_CALENDAR_FIELD = Calendar.MINUTE; 1203 DateIntervalInfo dii = new DateIntervalInfo(); 1204 try{ 1205 dii.getIntervalPattern("", Calendar.MINUTE+1); 1206 errln("DateIntervalInfo.getIntervalPattern(String,int) was suppose " + 1207 "to return an exception for the 'int field' parameter " + 1208 "when it exceeds MINIMUM_SUPPORTED_CALENDAR_FIELD."); 1209 } catch(Exception e){} 1210 } 1211 1212 /* Tests the method 1213 * public void setIntervalPattern(String skeleton, int lrgDiffCalUnit, String intervalPattern) 1214 */ TestSetIntervalPattern()1215 public void TestSetIntervalPattern(){ 1216 DateIntervalInfo dii = new DateIntervalInfo(); 1217 // Tests when "if ( frozen )" is true 1218 try{ 1219 dii.freeze(); 1220 dii.setIntervalPattern("", 0, ""); 1221 errln("DateIntervalInfo.setIntervalPattern(String,int,String) " + 1222 "was suppose to return an exception when the " + 1223 "DateIntervalInfo object is frozen."); 1224 } catch(Exception e){} 1225 1226 // Tests when "if ( lrgDiffCalUnit > MINIMUM_SUPPORTED_CALENDAR_FIELD )" is true 1227 // MINIMUM_SUPPORTED_CALENDAR_FIELD = Calendar.MINUTE; 1228 try{ 1229 dii = (DateIntervalInfo) dii.cloneAsThawed(); 1230 dii.setIntervalPattern("", Calendar.MINUTE+1, ""); 1231 errln("DateIntervalInfo.setIntervalPattern(String,int,String) " + 1232 "was suppose to return an exception when the " + 1233 "variable 'lrgDiffCalUnit' is greater than " + 1234 "MINIMUM_SUPPORTED_CALENDAR_FIELD."); 1235 } catch(Exception e){} 1236 } 1237 TestSetIntervalPatternNoSideEffect()1238 public void TestSetIntervalPatternNoSideEffect() { 1239 PatternInfo patternInfo = new DateIntervalInfo(ULocale.ENGLISH).getIntervalPattern("yMd", Calendar.DATE); 1240 String expectedPattern = patternInfo.getFirstPart() + patternInfo.getSecondPart(); 1241 new DateIntervalInfo(ULocale.ENGLISH).setIntervalPattern( 1242 "yMd", Calendar.DATE, "M/d/y \u2013 d"); 1243 patternInfo = new DateIntervalInfo(ULocale.ENGLISH).getIntervalPattern("yMd", Calendar.DATE); 1244 String actualPattern = patternInfo.getFirstPart() + patternInfo.getSecondPart(); 1245 assertEquals( 1246 "setIntervalPattern should not have side effects", 1247 expectedPattern, 1248 actualPattern); 1249 } 1250 TestGetSetTimeZone()1251 public void TestGetSetTimeZone(){ 1252 DateIntervalFormat dtitvfmt = DateIntervalFormat.getInstance("MMMdHHmm", Locale.ENGLISH); 1253 long date1 = 1299090600000L; // 2011-Mar-02 1030 in US/Pacific, 2011-Mar-03 0330 in Asia/Tokyo 1254 long date2 = 1299115800000L; // 2011-Mar-02 1730 in US/Pacific, 2011-Mar-03 1030 in Asia/Tokyo 1255 DateInterval dtitv = new DateInterval(date1, date2); 1256 TimeZone tzCalif = TimeZone.getFrozenTimeZone("US/Pacific"); 1257 TimeZone tzTokyo = TimeZone.getFrozenTimeZone("Asia/Tokyo"); 1258 String fmtCalif = "Mar 2, 10:30 \u2013 17:30"; // ICU4C result is "Mar 2, 10:30 \u2013 17:30" (does not duplicate day) 1259 String fmtTokyo = "Mar 3, 03:30 \u2013 10:30"; // ICU4C result is "Mar 3, 03:30 \u2013 10:30" (does not duplicate day) 1260 1261 StringBuffer buf = new StringBuffer(); 1262 FieldPosition pos = new FieldPosition(0); 1263 dtitvfmt.setTimeZone(tzCalif); 1264 dtitvfmt.format(dtitv, buf, pos); 1265 if (!buf.toString().equals(fmtCalif)) { 1266 errln("DateIntervalFormat for tzCalif, expect \"" + fmtCalif + "\", get \"" + buf + "\""); 1267 } 1268 1269 buf.setLength(0); 1270 pos.setBeginIndex(0); 1271 dtitvfmt.setTimeZone(tzTokyo); 1272 dtitvfmt.format(dtitv, buf, pos); 1273 if (!buf.toString().equals(fmtTokyo)) { 1274 errln("DateIntervalFormat for tzTokyo, expect \"" + fmtTokyo + "\", get \"" + buf + "\""); 1275 } 1276 1277 if (!dtitvfmt.getTimeZone().equals(tzTokyo)) { 1278 errln("DateIntervalFormat.getTimeZone() returns mismatch"); 1279 } 1280 } 1281 1282 1283 /* Tests the method 1284 * public int hashCode() 1285 */ TestHashCode()1286 public void TestHashCode(){ 1287 // Tests when 1288 // "int hash = fIntervalPatternFirstPart != null ? fIntervalPatternFirstPart.hashCode() : 0;" 1289 // is false 1290 PatternInfo dp = new PatternInfo(null, null, false); 1291 if(dp.hashCode() != 0){ 1292 errln("PatternInfo.hashCode() was suppose to return 0 for a null " + 1293 "paramter in the constructor."); 1294 } 1295 } 1296 1297 /* Tests the method 1298 * public boolean equals(Object a) 1299 * in PatternInfo 1300 */ TestPattternInfoEquals()1301 public void TestPattternInfoEquals(){ 1302 // Tests when "if ( a instanceof PatternInfo )" is false 1303 PatternInfo pi = new PatternInfo("","", false); 1304 if(pi.equals(new Object())){ 1305 errln("PatternInfo.equals(Object) is suppose to return false " + 1306 "when it is not an instance of PatternInfo."); 1307 } 1308 if(pi.equals("")){ 1309 errln("PatternInfo.equals(Object) is suppose to return false " + 1310 "when it is not an instance of PatternInfo."); 1311 } 1312 if(pi.equals(0)){ 1313 errln("PatternInfo.equals(Object) is suppose to return false " + 1314 "when it is not an instance of PatternInfo."); 1315 } 1316 if(pi.equals(0.0)){ 1317 errln("PatternInfo.equals(Object) is suppose to return false " + 1318 "when it is not an instance of PatternInfo."); 1319 } 1320 } 1321 TestDateIntervalCoverage()1322 public void TestDateIntervalCoverage() { 1323 DateInterval di = new DateInterval(0, 1); 1324 1325 if (di.equals("Test")) { 1326 errln("Comparison test should fail."); 1327 } 1328 1329 if (di.toString() == null) { 1330 errln("toString should not return null."); 1331 } 1332 1333 if (di.hashCode() != 1) { 1334 errln("hasCode() should return 1."); 1335 } 1336 } 1337 TestTicket9919GetInstance()1338 public void TestTicket9919GetInstance() { 1339 // Creating a DateIntervalFormat with a custom DateIntervalInfo 1340 // object used to corrupt the cache. 1341 DateIntervalFormat dif = DateIntervalFormat.getInstance( 1342 "yMd", ULocale.ENGLISH); 1343 Calendar from = Calendar.getInstance(); 1344 Calendar to = Calendar.getInstance(); 1345 from.set(2013, 3, 26); 1346 to.set(2013, 3, 28); 1347 1348 // Save. This is the correct answer 1349 String expected = 1350 dif.format(from, to, new StringBuffer(), new FieldPosition(0)) 1351 .toString(); 1352 1353 // Now create a DateIntervalFormat with same skeleton and 1354 // locale, but with a custom DateIntervalInfo. This used 1355 // to corrupt the cache. 1356 DateIntervalInfo dateIntervalInfo = 1357 new DateIntervalInfo(ULocale.ENGLISH); 1358 dateIntervalInfo.setIntervalPattern( 1359 "yMd", Calendar.DATE, "M/d/y \u2013 d"); 1360 DateIntervalFormat.getInstance( 1361 "yMd", ULocale.ENGLISH, dateIntervalInfo); 1362 1363 // Now create a DateIntervalFormat with same skeleton and 1364 // locale, but with default DateIntervalInfo. The cache should 1365 // not be corrupted, and we should get the same answer as before. 1366 dif = DateIntervalFormat.getInstance("yMd", ULocale.ENGLISH); 1367 1368 assertEquals( 1369 "Custom DateIntervalInfo objects should not mess up cache", 1370 expected, 1371 dif.format(from, to, new StringBuffer(), new FieldPosition(0)) 1372 .toString()); 1373 1374 } 1375 TestTicket9919Setter()1376 public void TestTicket9919Setter() { 1377 1378 // Creating a DateIntervalFormat with a custom DateIntervalInfo 1379 // object used to corrupt the cache. 1380 DateIntervalFormat dif = DateIntervalFormat.getInstance( 1381 "yMd", ULocale.ENGLISH); 1382 Calendar from = Calendar.getInstance(); 1383 Calendar to = Calendar.getInstance(); 1384 from.set(2013, 3, 26); 1385 to.set(2013, 3, 28); 1386 1387 // Save. This is the correct answer 1388 String expected = 1389 dif.format(from, to, new StringBuffer(), new FieldPosition(0)) 1390 .toString(); 1391 1392 // Now create a DateIntervalFormat with same skeleton and 1393 // locale, but with a custom DateIntervalInfo. This used 1394 // to corrupt the cache. 1395 DateIntervalInfo dateIntervalInfo = 1396 new DateIntervalInfo(ULocale.ENGLISH); 1397 dateIntervalInfo.setIntervalPattern( 1398 "yMd", Calendar.DATE, "M/d/y \u2013 d"); 1399 DateIntervalFormat bad = DateIntervalFormat.getInstance( 1400 "yMd", ULocale.ENGLISH); 1401 bad.setDateIntervalInfo(dateIntervalInfo); 1402 1403 // Now create a DateIntervalFormat with same skeleton and 1404 // locale, but with default DateIntervalInfo. The cache should 1405 // not be corrupted, and we should get the same answer as before. 1406 dif = DateIntervalFormat.getInstance("yMd", ULocale.ENGLISH); 1407 assertEquals( 1408 "Custom DateIntervalInfo objects should not mess up cache", 1409 expected, 1410 dif.format(from, to, new StringBuffer(), new FieldPosition(0)) 1411 .toString()); 1412 } 1413 TestTicket9914()1414 public void TestTicket9914() { 1415 DateIntervalInfo dateIntervalInfo = 1416 new DateIntervalInfo(ULocale.ENGLISH); 1417 1418 Calendar from = Calendar.getInstance(); 1419 Calendar to = Calendar.getInstance(); 1420 from.set(113, 3, 26); 1421 to.set(113, 3, 28); 1422 DateIntervalFormat dif = DateIntervalFormat.getInstance( 1423 "yyyyMd", ULocale.ENGLISH, dateIntervalInfo); 1424 assertEquals( 1425 "yyyyMd skeleton.", 1426 "4/26/0113 \u2013 4/28/0113", 1427 dif.format(from, to, new StringBuffer(), new FieldPosition(0)) 1428 .toString()); 1429 1430 dif = DateIntervalFormat.getInstance( 1431 "yyMd", ULocale.ENGLISH, dateIntervalInfo); 1432 assertEquals( 1433 "yyMd skeleton.", 1434 "4/26/13 \u2013 4/28/13", 1435 dif.format(from, to, new StringBuffer(), new FieldPosition(0)) 1436 .toString()); 1437 1438 dif = DateIntervalFormat.getInstance( 1439 "yMd", ULocale.ENGLISH, dateIntervalInfo); 1440 assertEquals( 1441 "yMd skeleton.", 1442 "4/26/113 \u2013 4/28/113", 1443 dif.format(from, to, new StringBuffer(), new FieldPosition(0)) 1444 .toString()); 1445 } 1446 TestTicket11583()1447 public void TestTicket11583 () { 1448 ULocale[] locales = { 1449 ULocale.ENGLISH, 1450 SPANISH, 1451 LA_SPANISH, 1452 }; 1453 String[] skeletons = { 1454 "yMMMMd", "yMMMM", "MMMM", 1455 "yMMMd", "yMMM", "MMM", 1456 "yMMd", "yMMdd", "yMM", "MM", 1457 "yMdd", "yMd", "yM", "M" 1458 }; 1459 1460 final long startDate = 1232364615000L; 1461 final long endDate = 1240399815000L; 1462 String filterPattern = null ; // "yMMM"; 1463 1464 for (ULocale locale : locales) { 1465 for (String skeleton : skeletons) { 1466 if (filterPattern != null && !skeleton.equals(filterPattern)) { 1467 continue; 1468 } 1469 1470 DateFormat dateFormat = DateFormat.getPatternInstance(skeleton, locale); 1471 String dateFormatPattern = ((SimpleDateFormat)dateFormat).toPattern(); 1472 1473 DateIntervalFormat intervalFormat = DateIntervalFormat.getInstance(skeleton, locale); 1474 DateIntervalInfo intervalInfo = intervalFormat.getDateIntervalInfo(); 1475 1476 if (skeleton.equals(filterPattern)) { 1477 logln(filterPattern + " => " + intervalInfo.getRawPatterns().get(filterPattern)); 1478 } 1479 1480 DateInterval date_interval = new DateInterval(startDate, endDate); 1481 1482 String interval = intervalFormat.format(date_interval); 1483 1484 String formattedStart = dateFormat.format(startDate); 1485 String formattedEnd = dateFormat.format(endDate); 1486 1487 PatternInfo patternInfo = intervalFormat.getRawPatterns().get("M"); 1488 1489 String firstPart = patternInfo.getFirstPart(); 1490 String secondPart = patternInfo.getSecondPart(); 1491 if (!matches(dateFormatPattern, firstPart, secondPart)) { 1492 if (logKnownIssue("11585", "incompatible pattern between date format and date interval format")) { 1493 logln("For skeleton " + skeleton + "/locale " + locale + ": mismatch between date format «" 1494 + dateFormatPattern + "» and date interval format «" + firstPart + secondPart + "»."); 1495 } else { 1496 errln("For skeleton " + skeleton + "/locale " + locale + ": mismatch between date format «" 1497 + dateFormatPattern + "» and date interval format «" + firstPart + secondPart + "»."); 1498 } 1499 } 1500 1501 logln(locale 1502 + "\tskeleton: «" + skeleton 1503 + "»\tpattern: «" + dateFormatPattern 1504 + "»\tintervalPattern1: «" + firstPart 1505 + "»\tintervalPattern2: «" + secondPart 1506 + "»\tstartDate: «" + formattedStart 1507 + "»\tendDate: «" + formattedEnd 1508 + "»\tinterval: «" + interval 1509 + "»" 1510 ); 1511 } 1512 } 1513 } 1514 1515 1516 /** 1517 * Return true if for some x, y: dateFormatPattern = firstPart(0,x) + secondPart(y, secondPart.length()) 1518 * @param dateFormatPattern 1519 * @param firstPart 1520 * @param secondPart 1521 * @return 1522 */ matches(String dateFormatPattern, String firstPart, String secondPart)1523 private boolean matches(String dateFormatPattern, String firstPart, String secondPart) { 1524 // brute force for now 1525 int lastButOne = dateFormatPattern.length()-1; 1526 for (int i = 1; i < lastButOne; ++i) { 1527 if (firstPart.startsWith(dateFormatPattern.substring(0,i)) 1528 && secondPart.endsWith(dateFormatPattern.substring(i,dateFormatPattern.length()))) { 1529 return true; 1530 } 1531 } 1532 return false; 1533 } 1534 } 1535