내가 요구 사항이있는, 내가의 startDate
(27JUL14
)와 endDate
(30JUN15
), 및 dayOfWeek
(4
, 5
, 6
)주 날짜와 주 일 둘 사이의 날짜
일을 제공 할 수 있습니다 주 대표 -
가1 - Monday
2 - Tuesday
3 - Wednesday
4 - Thursday
5 - Friday
6 - Saturday
7 - Sunday
startDate
과 endDate
사이의 기간은 6
개월 긴, 나는 01를 제공 일치하는 모든 특정 날짜를 얻을 필요 시간 간격에 대한은 StartDate
과 EndDate
사이입니다.
public void calculateScheduleDates(Date periodOfOperationFrom, Date periodOfOperationTo, String dow)
{
String[] weekDays = dow.replaceAll("\\[", "").replaceAll("\\]", "").split(",");
int[] dayOfWeek = new int[weekDays.length];
for (int i = 0; i < weekDays.length; i++)
{
try
{
dayOfWeek[i] = Integer.parseInt(weekDays[i]);
dateTime = (DateTime) DateTime.now().withDayOfWeek(dayOfWeek[i]);
System.out.println("DateTime :\t"+dateTime);
}
catch (NumberFormatException nfe) {};
}
}
나는
public void getWeekDate(String beginDate, String finishDate)
{
System.out.println("Begindate "+ beginDate + "\t EndDate \t"+finishDate);
LocalDate startDate = new LocalDate(2014, 12, 1);
LocalDate endDate = new LocalDate(2015, 6, 30);
/* These are date format for startDate and endDate which are not working with 27JUL14 format.
This also needs to be changed
*/
LocalDate thisMonday = startDate.withDayOfWeek(DateTimeConstants.MONDAY);
if (startDate.isAfter(thisMonday))
{
startDate = thisMonday.plusWeeks(1); // start on next monday
}
else
{
startDate = thisMonday; // start on this monday
}
while (startDate.isBefore(endDate))
{
dates.add(startDate);
startDate = startDate.plusWeeks(1);
}
System.out.println("Size of List Of Date :\t"+dates+"\n"+dates.size());
}
지금은 나무 상자 scheduleDates에 시도 (주 일 시작) 주를 얻기 위해 노력했다 :
public void calculateFlightLegScheduleDates(LocalDate[] periodOfOperationFrom, String dow)
{
/*
* Process as per the Weeks received from dates list and set it to current week and process
* alongwith dow and for each date, loop in to set the schedule Record.
* */
// the incoming weeks "periodOfOperationFrom" in list format, and I need to set the week starting date to the weeks start dates even in future and find the week dates from the dow parameter. This is the point where I am facing challenge.
}
나는 자바에서이 솔루션이 필요합니다.
jodatime
라이브러리를 사용하려고했지만 특정 결과를 얻을 수 없습니다.
참고 : 언급 된 기간 사이에 특정 일수가 필요합니다.
도와주세요.이게 많이 필요합니다.
당신이 더 나은 이해를 위해 샘플을 제공 할 수 있습니까? – Jens