아버지의 날과 어머니의 날과 같은 축제는 계산 될 수 있거나 회의 준비를 촉진하기 위해 매월 최고의 금요일로 정의 될 수 있습니다.
코드 사본은 다음과 같습니다.
/**
*
* @param strdate
* 시작 날짜, 형식 YYYY-MM-DD HH : MM : SS
* @Param CyclePriod
* 간격을 반복하십시오
* @param looppriod
* 반복 유형, m = 달, d = 일, y = y = w = 주, h = 시간, f = mine, s = second
* MN = 월의 긍정적 인 날은 언제입니까, MB = MB2가 마지막 두 번째 날이라면 월의 마지막 날은 얼마입니까?
* W1..7 = 매주의 날, MN1W2 = 월 첫 주, MB2W4 = 월의 두 번째 목요일
* W 이후의 값은 다중 값이 될 수 있으며 W135는 1 주차, 3 주 및 금요일을 나타냅니다.
* @param islunar
* 음력 일정이든, 통과 된 값은 태양 달력이어야하며, 반환 된 그레고리 캘린더는 음력에 따라 계산 후에도 태양열 캘린더입니다. 현재 음력은 몇 달과 몇 년 동안 다른 계산이 추가됩니다.
* @반품
*/
public static string nexttime (String strdate, int cyclpriod,
String looppriod, boolean islunar) {
문자열 returnValue = "";
int [] dates = dateUtils.gendate (strdate);
chinesecalendar ccalendar = 새로운 chinesecalendar ();
ccalendar.setGregorianyear (날짜 [0]);
ccalendar.SetGregorianmonth (날짜 [1]);
ccalendar.setGregoriandate (날짜 [2]);
if ( "m".equalsignorecase (looppriod)) // 월을 처리합니다
{
if (Islunar) {
for (int i = 0; i <cyclepriod; i ++) {
ccalendar.nextchinesemonth ();
}
returnValue = dateUtils.gendate (ccalendar.getGregorianyear (),
ccalendar.getGregorianmonth (),
ccalendar.getGregoriandate ());
} 또 다른 {
returnValue = dateUtils.caldate (strdate, cyclePriod, 2);
}
} else if ( "d".EqualSignoreCase (loopPriod)) // 처리 일
{
returnValue = dateUtils.caldate (strdate, cyclePriod, 5);
} else if ( "y".EqualSignoreCase (loopPriod)) // 프로세스 연도
{
if (Islunar) {
ccalendar.addchineseyear (CyclePriod);
returnValue = dateUtils.gendate (ccalendar.getGregorianyear (),
ccalendar.getGregorianmonth (),
ccalendar.getGregoriandate ());
} 또 다른 {
returnValue = dateUtils.caldate (strdate, cyclePriod, 1);
}
} else if ( "w".EqualSignoreCase (loopPriod)) // 처리 주
{
returnValue = dateUtils.caldate (strdate, cyclePriod, 3);
} else if ( "h".EqualSignoreCase (loopPriod)) // 처리 시간
{
returnValue = timeutils.addtime (strdate, 0, cyclepriod);
} else if ( "f".EqualSignoreCase (loopPriod)) // monges
{
returnValue = timeutils.addtime (strdate, 1, cyclepriod);
} else if ( "s".EqualSignoreCase (loopPriod)) // 초를 초당화합니다
{
returnValue = timeutils.addtime (strdate, 2, cyclepriod);
} else // 비 전통적인주기를 처리합니다
{
if ( "m".equalsignorecase (stringUtils.Left (loopPriod, 1))) {
문자열 mnb = looppriod.substring (1, 2);
문자열 wnb = "";
int mnbvalue = 0;
int wnbvalue = 0;
if (looppriod.indexof ( "w")> 1) {
wnb = looppriod.substring (looppriod.indexof ( "w") + 1,
looppriod.indexof ( "W") + 2);
mnbvalue = integer.parseint (looppriod.substring (2,
looppriod.indexof ( "w"));
wnbvalue = integer.parseint (looppriod.substring (
looppriod.indexof ( "w") + 1, looppriod.length ()));
if ( "n".equalsignorecase (mnb)) {
returnValue = getBeforeweekday (strdate, mnbvalue,
wnbvalue);
} else if ( "b".EqualSignoreCase (mnb)) {
returnValue = getbackweekday (strdate, mnbvalue,
wnbvalue);
}
} 또 다른 {
mnbvalue = integer.parseint (looppriod.substring (2,
looppriod.length ()) - 1;
if ( "n".equalsignorecase (mnb)) {
returnValue = caldate (Givemonthfirst (strdate),
mnbvalue, 5);
} else if ( "b".EqualSignoreCase (mnb)) {
returnValue = caldate (givemonthlast (strdate),
-mnbvalue, 5);
}
}
} else if ( "w".EqualSignoreCase (stringUtils.Left (loopPriod, 1))) {
String Week = StringUtils.right (looppriod,
looppriod.length () -1);
strdate = caldate (strdate, cyclepriod -1, 3);
while (true) {
strdate = caldate (strdate, 1, 5);
if (Week.indexof (String.valueof (getweekday (strdate))> = 0) {
returnValue = strdate;
부서지다;
}
}
}
}
return returnValue;
}