simple1
2753 ワード
public class SimpleProcess
{
private LinkedHashMap<Integer,ArrayList<Date>> exception = new LinkedHashMap<Integer, ArrayList<Date>>();
private LinkedHashMap<Integer,ArrayList<Date>> extra_weekend = new LinkedHashMap<Integer, ArrayList<Date>>();
private LinkedHashSet<Date> extra_weekday = new LinkedHashSet<Date>();
private SimpleDateFormat timeFormat = Const.timeFormat;
private Calendar am = Const.am;
private Calendar pm = Const.pm;
private Calendar eve = Const.eve;
// private Logger log = Logger.getLogger(Process.class);
public LinkedHashMap<Integer, ArrayList<Date>> getException()
{
return exception;
}
public void setException(
LinkedHashMap<Integer, ArrayList<Date>> exception)
{
this.exception = exception;
}
public LinkedHashMap<Integer, ArrayList<Date>> getExtra_weekend()
{
return extra_weekend;
}
public void setExtra_weekend(
LinkedHashMap<Integer, ArrayList<Date>> extra_weekend)
{
this.extra_weekend = extra_weekend;
}
public LinkedHashSet<Date> getExtra_weekday()
{
return extra_weekday;
}
public void setExtra_weekday(LinkedHashSet<Date> extra_weekday)
{
this.extra_weekday = extra_weekday;
}
// unique
@SuppressWarnings("unchecked")
private Map<Integer, ArrayList<Date>> uniqe(Map<Integer, ArrayList<Date>> map) throws ParseException
{
for(ArrayList<Date> ds:map.values())
{
if(ds.size() > 2)
{
Collections.sort(ds,new Comparator<Date>()
{
public int compare(Date o1, Date o2)
{
return o1.before(o2) ? -1 : 1;
}
});
ds.removeAll(((List<Date>) ds.clone()).subList(1, ds.size()-1));
}
else if(ds.size() == 1)
{
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(ds.get(0));
int date = cal.get(Calendar.DAY_OF_MONTH);
int day = cal.get(Calendar.DAY_OF_WEEK);
if(day == 1 || day == 7)
{
extra_weekend.put(date, new ArrayList<Date>(1));
extra_weekend.get(date).add(ds.get(0));
}
else
{
exception.put(date, new ArrayList<Date>(1));
exception.get(date).add(ds.get(0));
}
map.put(date, null);
}
}
return map;
}