Date format Issue in Java

I am using below simple date format in backend java to format the date which was given by user through user interface.

SimpleDateFormat sdf = new SimpleDateFormat("MMM");
SimpleDateFormat sdfMonthYear = new SimpleDateFormat("MMM-yyyy");
SimpleDateFormat sdfMonthYearDisplay = new SimpleDateFormat("MMM yyyy");

When It's deployed in my local machine It populates correct month value as Jan , Feb, Mar,Apr etc.But The proj now deployed in other server ex in Swedan's system .So now I am getting the month value as Maj instead of May and Okt instead of Oct.I have verifed that this month format is swedan based.I want a generic way of month format even Its deployed in any country like Jan ,Feb,may,Oct etc.

Please help me on this issue.

Jon Skeet
people
quotationmark

You just need to specify the locale when you create the SimpleDateFormat:

SimpleDateFormat sdf = new SimpleDateFormat("MMM", Locale.US);

Note that using one specific Locale for all users is typically appropriate for machine-to-machine communication - when you're parsing an ISO-8601 format, for example. To display a date to a user, you would normally use their locale and fetch an appropriate format, e.g.

DateFormat format = DateFormat.getDateInstance(DateFormat.LONG, userLocale);

people

See more on this question at Stackoverflow