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