/**** activequant - activestocks.eu This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. contact : contact@activestocks.eu homepage : http://www.activestocks.eu ****/ package com.activequant.utils; import java.util.Calendar; import java.util.Date; /** * @TODO desc<br> * <br> * <b>History:</b><br> * - [13.10.2007] Created (Erik Nijkamp)<br> * - [02.03.2008] Added getWeekday() (Erik Nijkamp)<br> * * @author Erik Nijkamp */ public class DateUtils { public enum Weekdays { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }; public static Date getDate(int day, int month, int year) { Calendar cal = Calendar.getInstance(); cal.set(year, month, day); return cal.getTime(); } public static Date nextDay(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DAY_OF_YEAR, 1); return cal.getTime(); } public static String getWeekday(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); int weekday = cal.get(Calendar.DAY_OF_WEEK) - 1; return Weekdays.values()[weekday].name(); } }