Skip to content

Commit 829f909

Browse files
committed
Add comments for legacy date formatters
1 parent 2d7b478 commit 829f909

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateFormatter.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ trait LegacyDateFormatter extends DateFormatter {
100100
}
101101
}
102102

103+
/**
104+
* The legacy formatter is based on Apache Commons FastDateFormat. The formatter uses the default
105+
* JVM time zone intentionally for compatibility with Spark 2.4 and earlier versions.
106+
*
107+
* Note: Using of the default JVM time zone makes the formatter compatible with the legacy
108+
* `DateTimeUtils` methods `toJavaDate` and `fromJavaDate` that are based on the default
109+
* JVM time zone too.
110+
*
111+
* @param pattern `java.text.SimpleDateFormat` compatible pattern.
112+
* @param locale The locale overrides the system locale and is used in parsing/formatting.
113+
*/
103114
class LegacyFastDateFormatter(pattern: String, locale: Locale) extends LegacyDateFormatter {
104115
@transient
105116
private lazy val fdf = FastDateFormat.getInstance(pattern, locale)
@@ -108,6 +119,22 @@ class LegacyFastDateFormatter(pattern: String, locale: Locale) extends LegacyDat
108119
override def validatePatternString(): Unit = fdf
109120
}
110121

122+
// scalastyle:off line.size.limit
123+
/**
124+
* The legacy formatter is based on `java.text.SimpleDateFormat`. The formatter uses the default
125+
* JVM time zone intentionally for compatibility with Spark 2.4 and earlier versions.
126+
*
127+
* Note: Using of the default JVM time zone makes the formatter compatible with the legacy
128+
* `DateTimeUtils` methods `toJavaDate` and `fromJavaDate` that are based on the default
129+
* JVM time zone too.
130+
*
131+
* @param pattern The pattern describing the date and time format.
132+
* See <a href="https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html">
133+
* Date and Time Patterns</a>
134+
* @param locale The locale whose date format symbols should be used. It overrides the system
135+
* locale in parsing/formatting.
136+
*/
137+
// scalastyle:on line.size.limit
111138
class LegacySimpleDateFormatter(pattern: String, locale: Locale) extends LegacyDateFormatter {
112139
@transient
113140
private lazy val sdf = new SimpleDateFormat(pattern, locale)

0 commit comments

Comments
 (0)