From a1d98c6dcdf387121139d1566f5b1924e2a02a75 Mon Sep 17 00:00:00 2001 From: German Schiavon <germanschiavon@gmail.com> Date: Wed, 13 Sep 2017 09:52:45 +0100 Subject: [PATCH] [SPARK-21982] Set locale to US ## What changes were proposed in this pull request? In UtilsSuite Locale was set by default to US, but at the moment of using format function it wasn't, taking by default JVM locale which could be different than US making this test fail. ## How was this patch tested? Unit test (UtilsSuite) Author: German Schiavon <germanschiavon@gmail.com> Closes #19205 from Gschiavon/fix/test-locale. --- core/src/main/scala/org/apache/spark/util/Utils.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 1e8250fd6a..bc08808a4d 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -1193,16 +1193,17 @@ private[spark] object Utils extends Logging { val second = 1000 val minute = 60 * second val hour = 60 * minute + val locale = Locale.US ms match { case t if t < second => - "%d ms".format(t) + "%d ms".formatLocal(locale, t) case t if t < minute => - "%.1f s".format(t.toFloat / second) + "%.1f s".formatLocal(locale, t.toFloat / second) case t if t < hour => - "%.1f m".format(t.toFloat / minute) + "%.1f m".formatLocal(locale, t.toFloat / minute) case t => - "%.2f h".format(t.toFloat / hour) + "%.2f h".formatLocal(locale, t.toFloat / hour) } } -- GitLab