package org.apache.solr.common.util;

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */

import java.text.ParseException;
import java.util.Date;

import org.apache.lucene.util.LuceneTestCase;

public class TestDateUtil extends LuceneTestCase {

  public void testCurrentTime() throws ParseException {
    long now = System.currentTimeMillis();
    assertParsedDate(now, new Date(now).toString(), 1000L);
  }
  
  public void testParseDate() throws ParseException {
    assertParsedDate(1226583351000L, "Thu Nov 13 04:35:51 AKST 2008", 0L);
  }
    
  private static void assertParsedDate(long ts, String dateStr, long epsilon) throws ParseException {
    System.out.println(DateUtil.parseDate(dateStr).getTime());
    assertTrue("Incorrect parsed timestamp", Math.abs(ts - DateUtil.parseDate(dateStr).getTime()) <= epsilon);
  }

}

@@ -889,16 +889,41 @@
 il.Date;
+%0Aimport java.util.Locale;
 %0A%0Aimport
@@ -1037,19 +1037,20 @@
 test
-CurrentTime
+DateToString
 () t
@@ -1085,40 +1085,27 @@
 ong 
-now = System.currentTimeMillis()
+ts = 1226583351000L
 ;%0A  
@@ -1123,19 +1123,18 @@
 sedDate(
-now
+ts
 , new Da
@@ -1140,11 +1140,10 @@
 ate(
-now
+ts
 ).to
@@ -1154,15 +1154,8 @@
 ng()
-, 1000L
 );%0A 
@@ -1286,12 +1286,8 @@
 008%22
-, 0L
 );%0A 
@@ -1360,22 +1360,8 @@
 eStr
-, long epsilon
 ) th
@@ -1390,27 +1390,22 @@
     
-System.out.println(
+long parsed = 
 Date
@@ -1437,17 +1437,16 @@
 etTime()
-)
 ;%0A    as
@@ -1458,101 +1458,135 @@
 rue(
-%22Incorrect parsed timestamp%22, Math.abs(ts - DateUtil.parseDate(dateStr).getTime()) %3C= epsilon
+String.format(Locale.ENGLISH, %22Incorrect parsed timestamp: %25d != %25d (%25s)%22, ts, parsed, dateStr), Math.abs(ts - parsed) %3C= 1000L
 );%0A 

Fix broken test - sorry!