Mega Code Archive

 
Categories / Java / Internationalization
 

Set MessageFormat to Locale US

import java.text.MessageFormat; import java.util.Date; import java.util.Locale; public class MessageFormatReuse {   public static void main(String args[]) {     String pattern = "{0}K was deleted on {1}.";     MessageFormat formatter = new MessageFormat(pattern);     Double kb = new Double(3.5);     Date today = new Date();     Object[] arguments = { kb, today };     formatter.setLocale(Locale.US);     System.out.println(formatter.format(arguments));   } }