mdayakar commented on code in PR #4760: URL: https://github.com/apache/hive/pull/4760#discussion_r1344540657
########## standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestMetaStoreUtils.java: ########## @@ -0,0 +1,78 @@ +/* + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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. + */ +package org.apache.hadoop.hive.metastore.utils; + +import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.sql.Date; +import java.sql.Timestamp; +import java.time.ZoneId; +import java.util.TimeZone; + +import static org.junit.Assert.assertEquals; + +@Category(MetastoreUnitTest.class) +public class TestMetaStoreUtils { Review Comment: > The issue was coming when SimpleDateFormat and java.sql.Date is used. Let me rephrase my question cause it was not completely clear. Can someone see the problem after switching the formatter behind MetaStoreUtils.convertDateToString using the unit tests here? Yes, the testcase fails when someone changes the formatter back to SimpleDateFormat. For example if I change like below ```java public static String convertDateToString(Date date) { DateFormat val = new SimpleDateFormat("yyyy-MM-dd"); val.setLenient(false); // Without this, 2020-20-20 becomes 2021-08-20. val.setTimeZone(TimeZone.getTimeZone("UTC")); return val.format(date); //return DATE_FORMATTER.format(date.toLocalDate()); } ``` then the testcases are failing ``` [ERROR] Failures: [ERROR] TestMetaStoreUtils.testConvertDateToString:46 expected:<202[3-01-0]1> but was:<202[2-12-3]1> [ERROR] TestMetaStoreUtils.testConvertStringToDateToString:72 expected:<202[3-01-0]1> but was:<202[2-12-3]1> [INFO] [ERROR] Tests run: 6, Failures: 2, Errors: 0, Skipped: 0 ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org