3
votes

I have try to convert date time to yyyy/MM/dd format using joda. but I got this error.

Invalid format: "2016-03-10T15:45:03.000+05:30" is malformed at "T15:45:03.000+05:30" : ()

here is my method

val dateFormatGeneration: DateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");
            def convertDateTime(dt:DateTime):String={
                dateFormatGeneration.parseDateTime(dt.toString).toString
            }

simply i need to convert joda datetime object to string as yyyy/MM/dd format

1

1 Answers

4
votes

As far as I can tell, the easiest would be to just use DateTimeFormatter's print() method:

val dateFormatGeneration: DateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");

def convertDateTime(dt:DateTime):String={
    dateFormatGeneration.print(dt)
}