String[] time;
SimpleDateFormat fromFormat = new SimpleDateFormat("yyyyMMddHHmmss"); SimpleDateFormat toFormat = new SimpleDateFormat("MM.dd"); try { for (int i = 0; i < timeList.length; i++) { time.set(i, toFormat.format(fromFormat.parse(time.get(i)))); } } catch (ParseException e) { e.printStackTrace(); }
将时间字符串20200811103503截取转化为08.11时间字符串
SimpleDateFormat.format把date转成String
SimpleDateFormat.parse把String转成date。