을 당신은 올바른 FROM 구문 분석한다 형식으로 변환 한 다음 다른 올바른 형식으로 TO 문자열로 변환하십시오. 뭐하시는 겁니까? yyyy-MM-dd
형식의 MM/dd/yyyy
형식으로 날짜를 해석하려고합니다. 즉 부정확합니다.
SAMPLE은
public static void main(String[] args) throws ParseException {
SimpleDateFormat sourceFormat = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat destinationFormat = new SimpleDateFormat("yyyy-MM-dd");
String sourceDateString = "02/16/2012";
String destinationDateString;
Date dat; // this object stores "perfect" date object
// interpreting string with input format and converting it to date
dat = sourceFormat.parse(sourceDateString);
// expressing date object as string in destination format
destinationDateString = destinationFormat.format(dat);
System.out.format("Done from %s to %s\n", sourceDateString, destinationDateString));
}