@tsolignani : I also face the same problem, especially when dealing with speech output. I have to get the day name in local language and speak it out. I create a list that contain the day name and then use index formatted from day to retrieve the list. The same can be done with month name.
Code: Select all
dayname = newList("Lunedi", "Martedi", "Mercoledi", "Giovedi", "Venerdi", "Sabato", "Domenica");
numday = "{triggertime,dateformat,u}"; //return 1 = Monday, to 7 = Sunday
dayitalian = dayname[numday-1]; //index start at 0, so need to minus 1
Pattern 'u' in dateformat only available from Nougat above. (For user below Nougat, can divide and get modulus of it.)
Other method is to use map for translation. This can be used for basically translation. You can create a full database to translate from one to another language or pattern/symbol.
Code: Select all
daydb = newMapFromValues(
"Monday", "Lunedi",
"Tuesday", "Martedi",
"Wednesday", "Mercoledi",
"Thursday", "Giovedi",
"Friday", "Venerdi",
"Saturday", "Sabato",
"Sunday", "Domenica");
dayenglish = "{triggertime,dateformat,EEEE}";
dayitalian = daydb[dayenglish];
if you use 'E' datepattern, then you should use "Mon" instead of "Monday". Change other day accordingly.
@anuraag : Java is always full of wonder, I don't know there is built-in function for that.