Android format Date and return Date as dd-MMM-yyyy

1k Views Asked by At

How can I format a Date String to pattern dd-MMM-yyyy and return the value as a date.?

I've used SimpleDateFormat("dd-MMM-yyyy").parse(date) but the return value is like Sun Oct 07 00:00:00 GMT+06:00 2018 but I need it like 07-Oct-2018

Any easy way to format and return as a date to dd-MMM-yyyy pattern.?

1

There are 1 best solutions below

0
On

You need to use DateFormat.parse(String), that will return a new Date object. For more information DateFormat