0

リストの日付を配列[][]に保存したいですか?

私のリストは

List<LocalDate> dates = getWeekendDates
        (new LocalDate(year, month, (day+2)), new LocalDate((year+1), nymonth ,nyday));

private static List<LocalDate> getWeekendDates
    (LocalDate start, LocalDate end)
{
    List<LocalDate> result = new ArrayList<LocalDate>();
    for (LocalDate date = start;
         date.isBefore(end);
         date = date.plusDays(1))
    {
        int day = date.getDayOfWeek();
        // These could be passed in...
        if (day == DateTimeConstants.SUNDAY)
        {
            result.add(date);
        }
    }
    return result;
}   

私が使用した:

String[] SundayArray = dates.toArray(new String[dates.size()]);
System.out.println(SundayArray[5]);

これはエラー出力です:

Exception in thread "main" java.lang.ArrayStoreException 
    at java.lang.System.arraycopy(Native Method) 
    at java.util.ArrayList.toArray(Unknown Source) 
    at Test.main(Test.java:27)

27行目はString[] SundayArray = dates.toArray(new String[dates.size()]);

4

1 に答える 1