Java에서 다음과 같은 날짜를 구문 분석 할 수 있습니까?
Sunday February 09th, 2014 or Sunday February 21st, 2014.
SimpleDateFormat으로 방법을 검색합니다. 감사
simpleDateformat을 사용하고 마스크를 사용해보십시오.
"E, dd MMMMM yyyy"
예 : 2014 년 2 월 9 일 일요일
simpleDateformat 내에서 th, rd 등을 추가 할 방법이 없습니다.이 작업을 수동으로 수행해야합니다.
// http://code.google.com/p/guava-libraries
import static com.google.common.base.Preconditions.*;
String getDayOfMonthSuffix(final int n) {
checkArgument(n >= 1 && n <= 31, "illegal day of month: " + n);
if (n >= 11 && n <= 13) {
return "th";
}
switch (n % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다