1. 程式人生 > >android初學------根據日期時間字串返回date資料 獲取年月日

android初學------根據日期時間字串返回date資料 獲取年月日

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");   
				Date date2;
				date2 = format.parse("2014-10-12");
				Calendar calendar=Calendar.getInstance();
				calendar.setTime(date2);

可以通過Calendar.setTime把日期設定進去 然後通過calendar.get(Calendar.YEAR)  。。。。。。獲取年月日