This is an automated email from the ASF dual-hosted git repository.

tbonelee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new d3f9fa01ec [ZEPPELIN-6483][FOLLOWUP] Format HDFS modification time 
with Locale.ROOT
d3f9fa01ec is described below

commit d3f9fa01ec453768307e2c971e5fdf1065d8e2e5
Author: 김동환 <[email protected]>
AuthorDate: Mon Aug 3 23:28:11 2026 +0900

    [ZEPPELIN-6483][FOLLOWUP] Format HDFS modification time with Locale.ROOT
    
    ### What is this PR for?
    Follow-up to #5351, addressing the non-blocking nit from the [approving 
review](https://github.com/apache/zeppelin/pull/5351#pullrequestreview-4820385490):
 `new SimpleDateFormat(pattern)` still takes its calendar and digits from the 
JVM default *locale*, so the same class of environment dependence survives the 
GMT fix — e.g. under a `th-TH` default locale the Buddhist calendar renders 
2015 as `2558-08-02 20:43GMT`.
    
    This change passes `Locale.ROOT` to the formatter in `listDate()` so the 
calendar and digits are stable regardless of the JVM default locale, exactly as 
suggested in the review.
    
    The new test mirrors the structure of 
`testListDateFormatsInGmtToMatchLabel` (save/restore of the global default in 
`finally`), switching the default locale to `th-TH` and asserting the listing 
still shows `2015-08-02 20:43GMT`. Reverting only the `listDate()` change makes 
it fail with the Buddhist-calendar output (`2558-08-02 20:43GMT`), so it pins 
the regression rather than asserting current behaviour.
    
    ### What type of PR is it?
    Improvement
    
    ### Todos
    * [x] - Pass `Locale.ROOT` to the `SimpleDateFormat` in `listDate()`
    * [x] - Add a regression test that fails without the fix
    
    ### What is the Jira issue?
    * https://issues.apache.org/jira/browse/ZEPPELIN-6483 (resolved by #5351; 
this is the follow-up allowed in its review)
    
    ### How should this be tested?
    * `./mvnw test -pl file -Dtest=HDFSFileInterpreterTest` — 8 tests green (7 
existing + 1 new)
    * Verified locally that reverting only the `listDate()` change makes 
`testListDateFormatsWithRootLocale` fail with `2558-08-02 20:43GMT` (Buddhist 
calendar year) in the listing
    
    ### Screenshots (if appropriate)
    
    ### Questions:
    * Does the license files need to update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    
    Closes #5370 from dev-donghwan/ZEPPELIN-6483-followup.
    
    Signed-off-by: ChanHo Lee <[email protected]>
---
 .../apache/zeppelin/file/HDFSFileInterpreter.java  |  5 ++++-
 .../zeppelin/file/HDFSFileInterpreterTest.java     | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git 
a/file/src/main/java/org/apache/zeppelin/file/HDFSFileInterpreter.java 
b/file/src/main/java/org/apache/zeppelin/file/HDFSFileInterpreter.java
index 662d02add8..43acdec766 100644
--- a/file/src/main/java/org/apache/zeppelin/file/HDFSFileInterpreter.java
+++ b/file/src/main/java/org/apache/zeppelin/file/HDFSFileInterpreter.java
@@ -27,6 +27,7 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Locale;
 import java.util.Properties;
 import java.util.TimeZone;
 
@@ -174,7 +175,9 @@ public class HDFSFileInterpreter extends FileInterpreter {
   }
 
   private String listDate(OneFileStatus fs) {
-    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+    // Locale.ROOT keeps the calendar and digits stable regardless of the JVM
+    // default locale (e.g. Buddhist calendar under th-TH).
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", 
Locale.ROOT);
     // Format in GMT so the value matches the "GMT" label appended in 
listOne(),
     // regardless of the JVM default time zone.
     sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
diff --git 
a/file/src/test/java/org/apache/zeppelin/file/HDFSFileInterpreterTest.java 
b/file/src/test/java/org/apache/zeppelin/file/HDFSFileInterpreterTest.java
index dc4dcbe5cc..81b5da80d2 100644
--- a/file/src/test/java/org/apache/zeppelin/file/HDFSFileInterpreterTest.java
+++ b/file/src/test/java/org/apache/zeppelin/file/HDFSFileInterpreterTest.java
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Properties;
 import java.util.TimeZone;
 
@@ -205,6 +206,27 @@ class HDFSFileInterpreterTest {
     }
   }
 
+  @Test
+  void testListDateFormatsWithRootLocale() {
+    // ZEPPELIN-6483 follow-up: the timestamp must not depend on the JVM 
default
+    // locale either — under th-TH the CLDR default calendar is Buddhist, which
+    // would render 2015 as 2558 without Locale.ROOT in listDate().
+    Locale original = Locale.getDefault();
+    try {
+      Locale.setDefault(Locale.forLanguageTag("th-TH"));
+      HDFSFileInterpreter t = new MockHDFSFileInterpreter(new Properties());
+      t.open();
+      InterpreterResult result = t.interpret("ls -l /", null);
+      String out = result.message().get(0).getData();
+      // modificationTime 1438548219672 == 2015-08-02 20:43 GMT
+      assertTrue(out.contains("2015-08-02 20:43GMT"),
+          "modification time should not depend on the default locale, but 
was:\n" + out);
+      t.close();
+    } finally {
+      Locale.setDefault(original);
+    }
+  }
+
 }
 
 /**

Reply via email to