001 package market;
002
003 import java.text.SimpleDateFormat;
004 import java.util.Calendar;
005 import java.util.GregorianCalendar;
006
007 /**
008 * The time format used by the market. This is merely a GregorianCalendar with an overwritten
009 * toString() method.
010 */
011 public class MarketCalendar extends GregorianCalendar {
012
013 public MarketCalendar() {
014 super();
015 }
016
017 /**
018 * @param year the new Calendar's year.
019 * @param month the new Calendar's month.
020 * @param date the new Calendar's date.
021 */
022 public MarketCalendar(int year, int month, int date) {
023 super(year, month, date);
024 }
025
026 /**
027 * Takes an arbitrary Calenar and creates a MarketCalendar from it.
028 * @param gc the original Calendar.
029 * @return a MarketCalendar representing the same date as the passed Calendar.
030 */
031 public static MarketCalendar create(Calendar gc) {
032 return new MarketCalendar(gc.get(YEAR), gc.get(MONTH), gc.get(DATE));
033 }
034
035 /**
036 * @return the Calendar as dd.MM.yyyy (e.g. 01.01.2000).
037 */
038 public String toString() {
039 SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
040 return sdf.format(getTime());
041 }
042 }