Im using SimpleDateFormat to parse the correct date.
Sometimes when i use SimpleDateFormat it returns the me the date in other language than english.
I want the date string to be only in english. Is the possible?
See my code and pictures.
Here is my formater:
SimpleDateFormat df = new SimpleDateFormat("d-MMMM-yyyy", Locale.ENGLISH);
Here is same app but string is in different languages:
Thanks for helping
Let us look at an example for formatting date using SimpleDateFormat. String pattern = "MM-dd-yyyy"; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); String date = simpleDateFormat. format(new Date()); System. out.
SimpleDateFormat format() Method in Java with Examples Return Value: The method returns Date or time in string format of mm/dd/yyyy.
Format date with SimpleDateFormat('MM/dd/yy') in Java // displaying date Format f = new SimpleDateFormat("MM/dd/yy"); String strDate = f. format(new Date()); System. out. println("Current Date = "+strDate);
You have to change
SimpleDateFormat df = new SimpleDateFormat("d-MMMM-yyyy", Locale.ENGLISH);
to
SimpleDateFormat df = new SimpleDateFormat("d-MMMM-yyyy", Locale.US);
SimpleDateFormat df = new SimpleDateFormat("d-MMMM-yyyy", new Locale("ar")); //for example arabic laguage
you ca check here for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With