tl;dr
LocalDateTime.parse(
"2010-01-25-12.40.35.769000" ,
DateTimeFormatter.ofPattern( "uuuu-MM-dd-HH.mm.ss.SSSSSS" )
)
Using java.time
You are using troublesome old date-time classes that are now legacy, supplanted by the java.time classes.
These old classes were limited to tracking milliseconds, three digits of decimal fraction. The modern java.time classes resolve to nanoseconds, for nine digits of decimal fraction.
DateTimeFormatter f = DateTimeFormatter.ofPattern( "uuuu-MM-dd-HH.mm.ss.SSSSSS" ) ;
LocalDateTime ldt = LocalDateTime.parse( "2010-01-25-12.40.35.769000" );
ldt.toString(): 2010-01-25T12:40:35.769
ISO 8601
Tip: Rather than invent your own format to textually represent a date-time value, stick to the standard ISO 8601 formats.
The java.time classes use the standard formats by default. You can see that format in the output above. The T
separates the date portion from the time-of-day portion.
About java.time
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date
, Calendar
, & SimpleDateFormat
.
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
Where to obtain the java.time classes?
The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval
, YearWeek
, YearQuarter
, and more.