Hi I have Date time format with century I was trying to convert it into string using Joda date time format but I am getting junk data while converting it I am not sure why this is happening
Code
LocalDate date = LocalDate.now();
DateTimeFormatter fmt = DateTimeFormat.forPattern("CCYYMMDDHHMMSSsss");
String str = date.toString(fmt);
System.out.println(str);
this is the output
20170103��0100���
but output should come like this
20160620091223711
If you want the current date and time to be formatted, you should try this:
Here, a
DateTime
object is used, the pattern is according to specification and the print method ofDateTimeFormatter
is used.