Different Operating Systems usually require a different syntax. A good example is the file separator char, the line separator or the path separator.
In order not to hard code these values on your source code there's the System.getProperty(String str) static method that receives a String and returns the desired property.
Take a look at http://java.sun.com/docs/books/tutorial/essential/environment/sysprop.html for further information.
quarta-feira, 3 de junho de 2009
Java: get Locale Date String
After struggling with the GregorianCalendar, Date and DateFormat classes for a while, here's a simple wrapper to replace the now deprecated date.getLocalizedString():
public static String getLocaleDate(Date date, Locale locale) {
return SimpleDateFormat.getDateInstance(
SimpleDateFormat.SHORT,locale).format(date).toUpperCase();
}
public static String getLocaleDate(Date date, Locale locale) {
return SimpleDateFormat.getDateInstance(
SimpleDateFormat.SHORT,locale).format(date).toUpperCase();
}
Subscrever:
Mensagens (Atom)