I set Japanese date using Locale (e.g. 21 11月 2016) in my android app. But, I want to send that date into "dd-MM-yyyy" (e.g. 21-11-2016) format to my APIs.
When I try to do this I get below exception :
java.lang.IllegalArgumentException: Bad class: class java.lang.String
Below is my code :
public String convertDate(String date) {
System.out.println("......ORIGINAL DATE....... " + date); // ......ORIGINAL DATE....... 21 11月 2016
String myFormat = "dd-MM-yyyy"; //In which you need put here
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, new Locale(getMyLocale())); //Japanese locale is set but tried english too
System.out.println("......CONVERTED DATE....... " + sdf.format(date)); //should be 21-11-2016 but getting above error
return sdf.format(new Date(date));
}
Moreover, for US/English Locale it works fine but for Japanese I am getting this error.