@@ -170,6 +170,57 @@ val df = DataFrame.readCSV(
170170
171171<!-- -END-->
172172
173+ ### Work with specific date-time formats
174+
175+ When parsing date or date-time columns, you might encounter formats different from the default ` ISO_LOCAL_DATE_TIME ` .
176+ Like:
177+
178+ <table >
179+ <tr ><th >date</th ></tr >
180+ <tr ><td >13/Jan/23 11:49 AM</td ></tr >
181+ <tr ><td >14/Mar/23 5:35 PM</td ></tr >
182+ </table >
183+
184+ Because the format here ` "dd/MMM/yy h:mm a" ` differs from the default (` ISO_LOCAL_DATE_TIME ` ),
185+ columns like this may be recognized as simple ` String ` values rather than actual date-time columns.
186+
187+ You can fix this whenever you [ parse] ( parse.md ) a string-based column (e.g., using [ ` DataFrame.readCSV() ` ] ( read.md#read-from-csv ) ,
188+ [ ` DataFrame.readTSV() ` ] ( read.md#read-from-csv ) , or [ ` DataColumn<String>.convertTo<>() ` ] ( convert.md ) ) by providing
189+ a custom date-time pattern. There are two ways to do this:
190+
191+ 1 ) By providing the date-time pattern as raw string to the ` ParserOptions ` argument:
192+
193+ <!-- -FUN readNumbersWithSpecificDateTimePattern-->
194+
195+ ``` kotlin
196+ val df = DataFrame .readCSV(
197+ file,
198+ parserOptions = ParserOptions (dateTimePattern = " dd/MMM/yy h:mm a" )
199+ )
200+ ```
201+ <!-- -END-->
202+
203+ 2 ) By providing a ` DateTimeFormatter ` to the ` ParserOptions ` argument:
204+
205+ <!-- -FUN readNumbersWithSpecificDateTimeFormatter-->
206+
207+ ``` kotlin
208+ val df = DataFrame .readCSV(
209+ file,
210+ parserOptions = ParserOptions (dateTimeFormatter = DateTimeFormatter .ofPattern(" dd/MMM/yy h:mm a" ))
211+ )
212+ ```
213+
214+ <!-- -END-->
215+ These two approaches are essentially the same, just specified in different ways.
216+ The result will be a dataframe with properly parsed ` DateTime ` columns.
217+
218+ > Note: Although these examples focus on reading CSV files,
219+ > these ` ParserOptions ` can be supplied to any ` String ` -column-handling operation
220+ > (like, ` readCsv ` , ` readTsv ` , ` stringCol.convertTo<>() ` , etc.)
221+ > This allows you to configure the locale, null-strings, date-time patterns, and more.
222+ >
223+ > For more details on the parse operation, see the [ ` parse operation ` ] ( parse.md ) .
173224
174225## Read from JSON
175226
0 commit comments