Im having difficulty converting the following date string "2014-07-10T11:31:35"
to a java Date object in android.
so Date date = new Date("2014-07-10T11:31:35");
returns null, which causes a null reference exception
public class DateUtil {
public static String FromIsoString(String datestring)
{
String formattedDateString = "";
try {
if (!datestring.isEmpty()) {
Date date = new Date(date string);//-->>>> returns null
String format = "dd/MM/yyyy";
Locale locale = Locale.ENGLISH;
formattedDateString = FromIsoString(date, format, locale);
}
}
catch(Exception ex)
{
Log.e(ex.getLocalizedMessage(),"FromUtcString");
}
return formattedDateString;
}
public static String FromIsoString(Date date, String format, Locale locale){
String dateString = null;
try
{
dateString = new SimpleDateFormat(format, locale).format(date);
}catch (Exception ex)
{
Log.e(ex.getLocalizedMessage(),"FromString");
}
return dateString;
}
}