I have a function as below to generate unique ID for my application
public static String now(String dateFormat) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
return sdf.format(cal.getTime());
}
I call the function using following way
incident_id = IncidentIdGenerator.now("ddMMyyyyHHmmss");
problem occures when I change the Locale. For an example if I change the locale to Arab, unique ID is generated in some arab letters. Arab letters are not supported in the web service which I’m gonna call.
I must stick to Locale.US when creating unique ID. How can I acheive this?? I tried as below but it didn’t work too.
Calendar cal = Calendar.getInstance(Locale.US);
Thanks for yoru time in advance.
You also have to specify
Locale.USwith yourSimpleDateFormat.