Assuming you mean Java, I suggest you to consider the class java.text.DateFormat
. Background is that every country/locale has its own typical date-time-format. For example:
public static String getDateFromCalendar(Calendar cal) {
// maybe get user-locale via ThreadLocal or via second method parameter
Locale locale = new Locale("ru", "Ru");
DateFormat dateFormat =
DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
return dateFormat.format(cal.getTime());
}
You can adjust the format style by choosing between SHORT, MEDIUM, LONG or FULL. For MEDIUM the output is: 05.04.2014
Compare that with the output for Locale.US
yielding: Apr 5, 2014
.