

regex matching (Currently limited to filename).It includes several options for selecting files, including: If you're interested, here's a list of all DateTimeFormatter patterns.The Multiple File Kotlin Converter IntelliJ IDEA plugin runs the native Convert Java File To Kotlin File action against a list of files, There are other styles as well: Full, Long and Short. In the above program, we've used a Localized style Medium to get the current date time in the given format. When you run the program, the output will be: Current Date is: 11:44:19 AM

Val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) In the above program, we've used a predefined format constant BASIC_ISO_DATE to get the current ISO date as the output.Įxample 4: Get Current Date time in localized style import When you run the program, the output will be: Current Date is: 20170802 Val formatter = DateTimeFormatter.BASIC_ISO_DATE This gets us the formatted string output.Įxample 3: Get Current Date time using predefined constants import Then, we've used LocalDateTime's format() method to use the given formatter. In the above program, we've defined a pattern of format Year-Month-Day Hours:Minutes:Seconds.Milliseconds using a DateTimeFormatter object. When you run the program, the output will be: Current Date and Time is: 11:29:57.401 Println("Current Date and Time is: $formatted") Val formatted = current.format(formatter) Val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS") In the above program, the current date and time is stored in variable current using LocalDateTime.now() method.įor default format, it is simply converted from a LocalDateTime object to a string using a toString() method.Įxample 2: Get Current date and time with pattern import When you run the program, the output will be: Current Date and Time is: T11:25:44.973

Println("Current Date and Time is: $current") Example 1: Get Current date and time in default format import
