Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleDateFormat returns string date in different languages

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:

enter image description here

enter image description here

Thanks for helping

like image 559
dasdasd Avatar asked Jul 02 '13 09:07

dasdasd


People also ask

How do I change date format in SimpleDateFormat?

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.

What does SimpleDateFormat return?

SimpleDateFormat format() Method in Java with Examples Return Value: The method returns Date or time in string format of mm/dd/yyyy.

How do you change date format to MM DD YYYY in java?

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);


2 Answers

You have to change

SimpleDateFormat df = new SimpleDateFormat("d-MMMM-yyyy", Locale.ENGLISH);

to

SimpleDateFormat df = new SimpleDateFormat("d-MMMM-yyyy", Locale.US);
like image 170
Shani Goriwal Avatar answered Nov 10 '22 03:11

Shani Goriwal


SimpleDateFormat df = new SimpleDateFormat("d-MMMM-yyyy", new Locale("ar")); //for example arabic laguage

you ca check here for more details.

like image 31
Adham Gamal Avatar answered Nov 10 '22 05:11

Adham Gamal