1 /* 2 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4267450 27 * @summary Unit test for week date support 28 */ 29 30 import java.text.*; 31 import java.util.*; 32 import static java.util.GregorianCalendar.*; 33 34 public class WeekDateTest { 35 static SimpleDateFormat ymdFormat = new SimpleDateFormat("yyyy-MM-dd"); 36 static SimpleDateFormat ywdFormat = new SimpleDateFormat("YYYY-'W'ww-u"); 37 static { 38 ymdFormat.setCalendar(newCalendar()); 39 ywdFormat.setCalendar(newCalendar()); 40 } 41 42 // Round-trip Data 43 static final String[][] roundTripData = { 44 { "2005-01-01", "2004-W53-6" }, 45 { "2005-01-02", "2004-W53-7" }, 46 { "2005-12-31", "2005-W52-6" }, 47 { "2007-01-01", "2007-W01-1" }, 48 { "2007-12-30", "2007-W52-7" }, 49 { "2007-12-31", "2008-W01-1" }, 50 { "2008-01-01", "2008-W01-2" }, 51 { "2008-12-29", "2009-W01-1" }, 52 { "2008-12-31", "2009-W01-3" }, 53 { "2009-01-01", "2009-W01-4" }, 54 { "2009-12-31", "2009-W53-4" }, 55 { "2010-01-03", "2009-W53-7" }, 56 { "2009-12-31", "2009-W53-4" }, | 1 /* 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 4267450 27 * @summary Unit test for week date support 28 */ 29 30 import java.text.*; 31 import java.util.*; 32 import static java.util.GregorianCalendar.*; 33 34 public class WeekDateTest { 35 static SimpleDateFormat ymdFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); 36 static SimpleDateFormat ywdFormat = new SimpleDateFormat("YYYY-'W'ww-u", Locale.US); 37 static { 38 ymdFormat.setCalendar(newCalendar()); 39 ywdFormat.setCalendar(newCalendar()); 40 } 41 42 // Round-trip Data 43 static final String[][] roundTripData = { 44 { "2005-01-01", "2004-W53-6" }, 45 { "2005-01-02", "2004-W53-7" }, 46 { "2005-12-31", "2005-W52-6" }, 47 { "2007-01-01", "2007-W01-1" }, 48 { "2007-12-30", "2007-W52-7" }, 49 { "2007-12-31", "2008-W01-1" }, 50 { "2008-01-01", "2008-W01-2" }, 51 { "2008-12-29", "2009-W01-1" }, 52 { "2008-12-31", "2009-W01-3" }, 53 { "2009-01-01", "2009-W01-4" }, 54 { "2009-12-31", "2009-W53-4" }, 55 { "2010-01-03", "2009-W53-7" }, 56 { "2009-12-31", "2009-W53-4" }, |