Java Code Examples for ims.framework.utils.Date.getDayOfWeek()

The following are Jave code examples for showing how to use getDayOfWeek() of the ims.framework.utils.Date class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AvoinApotti   File: Logic.java   Source Code and License Vote up 6 votes
private Date validateStartDateIsSunday(Date dt)
{
	if (dt == null)
		return null;

	DayOfWeek weekDay = dt.getDayOfWeek();
	if (!weekDay.equals(DayOfWeek.SUNDAY))
	{
		if (weekDay.equals(DayOfWeek.MONDAY))
			dt.addDay(-1);
		if (weekDay.equals(DayOfWeek.TUESDAY))
			dt.addDay(-2);
		if (weekDay.equals(DayOfWeek.WEDNESDAY))
			dt.addDay(-3);
		if (weekDay.equals(DayOfWeek.THURSDAY))
			dt.addDay(-4);
		if (weekDay.equals(DayOfWeek.FRIDAY))
			dt.addDay(-5);
		if (weekDay.equals(DayOfWeek.SATURDAY))
			dt.addDay(-6);

		return new Date(dt);
	}

	return null;
}
 
Example 2
Project: AvoinApotti   File: SpecimenCollectionConfigImpl.java   Source Code and License Vote up 5 votes
private DayOfWeek getDayOfWeek(Date date)
{
	if(date == null)
		throw new CodingRuntimeException("Coding Error = date is null (getDayOfWeek) ");
	
	DomainFactory factory = getDomainFactory();
	List hols = factory.find("from PublicHolidays hol where hol.date = :date", new String[]{"date"}, new Object[] {date.getDate()});
	if(hols != null && hols.size() > 0)
		return DayOfWeek.PUBLICHOLIDAY;
		
	DayOfWeek inst = null;
	ims.framework.utils.DayOfWeek day = date.getDayOfWeek();
	
	if(day.equals(ims.framework.utils.DayOfWeek.MONDAY))
		inst = DayOfWeek.MONDAY;
	else if(day.equals(ims.framework.utils.DayOfWeek.TUESDAY))
		inst = DayOfWeek.TUESDAY;
	else if(day.equals(ims.framework.utils.DayOfWeek.WEDNESDAY))
		inst = DayOfWeek.WEDNESDAY;
	else if(day.equals(ims.framework.utils.DayOfWeek.THURSDAY))
		inst = DayOfWeek.THURSDAY;
	else if(day.equals(ims.framework.utils.DayOfWeek.FRIDAY))
		inst = DayOfWeek.FRIDAY;
	else if(day.equals(ims.framework.utils.DayOfWeek.SATURDAY))
		inst = DayOfWeek.SATURDAY;
	else if(day.equals(ims.framework.utils.DayOfWeek.SUNDAY))
		inst = DayOfWeek.SUNDAY;
	
	return inst;
}