// Sample output: 20180420-121341LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd-kkmmss"))
Check for format pattern
You can also used pre-defined DateTimeFormatter
ISO_LOCAL_DATE_TIME
: e.g.2011-12-03T10:15:30.111222
BASIC_ISO_DATE
: e.g.20111203
ISO_LOCAL_DATE
: e.g.2011-12-03
ISO_LOCAL_TIME
: e.g.10:15:30
ISO_OFFSET_DATE_TIME
: e.g.2011-12-03T10:15:30+01:00
RFC_1123_DATE_TIME
: e.g.Tue, 3 Jun 2008 11:05:30 GMT
// Sample output: 2018-04-10T03:34:18.115LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)