ADDITIONAL SYSTEM INFORMATION :
Tested on Windows, Mac OS, Ubuntu Linux on Java versions 8, 9, 11.
A DESCRIPTION OF THE PROBLEM :
When using DateTimeFormatter.ISO_LOCAL_DATE_TIME and any other value, from Java 9 and onwards the format will always contain nanoseconds in the ending, like '2019-04-16T13:32:50.694395' in spite of documentation giving the explicit example '2011-12-03T10:15:30'. For java 8 however it will provide the exact same format as the documentation example. This should either be reflected in documentation from version 9 and onward, or change the behavior to be in line with the documentation.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code in java 9
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A date formatted like '2019-04-16T13:39:45'
ACTUAL -
A date formatted like '2019-04-16T13:39:45.272079'
---------- BEGIN SOURCE ----------
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
public class Main {
public static void main(String[] args) {
ZonedDateTime dateTime = ZonedDateTime.now();
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.append(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
.toFormatter();
String answerTime = formatter.format(dateTime);
System.out.println(answerTime);
}
}
---------- END SOURCE ----------
FREQUENCY : always
Tested on Windows, Mac OS, Ubuntu Linux on Java versions 8, 9, 11.
A DESCRIPTION OF THE PROBLEM :
When using DateTimeFormatter.ISO_LOCAL_DATE_TIME and any other value, from Java 9 and onwards the format will always contain nanoseconds in the ending, like '2019-04-16T13:32:50.694395' in spite of documentation giving the explicit example '2011-12-03T10:15:30'. For java 8 however it will provide the exact same format as the documentation example. This should either be reflected in documentation from version 9 and onward, or change the behavior to be in line with the documentation.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code in java 9
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A date formatted like '2019-04-16T13:39:45'
ACTUAL -
A date formatted like '2019-04-16T13:39:45.272079'
---------- BEGIN SOURCE ----------
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
public class Main {
public static void main(String[] args) {
ZonedDateTime dateTime = ZonedDateTime.now();
DateTimeFormatter formatter = new DateTimeFormatterBuilder()
.append(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
.toFormatter();
String answerTime = formatter.format(dateTime);
System.out.println(answerTime);
}
}
---------- END SOURCE ----------
FREQUENCY : always