I\'m new to both Java and Android development so this might be a stupid question, but I\'ve been searching for days now and can\'t find a solution:
I try to output a
public static String formatDate(Date date, boolean withTime)
{
String result = "";
DateFormat dateFormat;
if (date != null)
{
try
{
String format = Settings.System.getString(context.getContentResolver(), Settings.System.DATE_FORMAT);
if (TextUtils.isEmpty(format))
{
dateFormat = android.text.format.DateFormat.getDateFormat(context);
}
else
{
dateFormat = new SimpleDateFormat(format);
}
result = dateFormat.format(date);
if (withTime)
{
dateFormat = android.text.format.DateFormat.getTimeFormat(context);
result += " " + dateFormat.format(date);
}
}
catch (Exception e)
{
}
}
return result;
}