date为原始日期,orignalFormat为原始日期格式,expectedFormat为预期日期格式
def convertDate(String date, String originalFormat, String expectedFormat){ SimpleDateFormat dateFormat1 = new SimpleDateFormat(originalFormat) SimpleDateFormat dateFormat2 = new SimpleDateFormat(expectedFormat) try{ String dateStr = dateFormat2.format(dateFormat1.parse(date)) return dateStr }catch(Exception e){ e.getMessage() } }