【发布时间】:2015-04-16 06:04:16
【问题描述】:
我将日期作为单个string 存储在数据库中,格式为“2 15 2015”(大概是“M d yyyy”?)。下面代码中的strDate 包含获取日期的方法的返回值。我想解析日期以设置datepicker。基于Java string to date conversion中的示例
我创建了以下代码来解析日期,但在
处得到一个“Unhandled Exception: java.text.ParseException”
Date date = format.parse(strDate);
挠头。
Calendar mydate = new GregorianCalendar();
String strDate = datasource.get_Column_StrVal(dbData,
MySQLiteHelper.dbFields.COLUMN_SPECIAL_DAYS_DATE);
SimpleDateFormat format = new SimpleDateFormat("M d yyyy", Locale.ENGLISH);
Date date = format.parse(strDate);
mydate.setTime(date);
【问题讨论】: