package w3c.rtsp.common;

import java.io.*;
import java.util.*;
import java.net.*;
import java.awt.*;


public class RtspDate {

  public  String weekday=null;
  public String GMTDate=null;

  //constructor used if the date is built with year,month,day(0-(30-31)),hours,min and seconds.

  public RtspDate(){
  }

  public RtspDate(Date myDate){
    weekday=whatDayWeek(myDate);
    GMTDate=myDate.toGMTString();
  }

  //Constructor used if the date is built between the parse.

  public RtspDate(String date){
    if(date!=null){
    this.weekday=date.substring(0,3);
    this.GMTDate=date.substring(4);
    }
  }


  //return the day of the week of the specified date.

  public String whatDayWeek(Date myDate){

    switch(myDate.getDay()){
    case 0 :
      return "Sun";
    case 1 :
      return "Mon";
    case 2 :
      return "Tue";
    case 3 :
      return "Wen";
    case 4 :
      return "Thu";
    case 5 :
      return "Fri";
    case 6 :
      return "Sat";
    }
    return null;
  }
  
  //do not forget the , and the space for the format of this kind of date.

  public String toString(){
    System.out.println("\nDATE:"+weekday+GMTDate);
    return new String("Date: "+weekday+","+GMTDate);
  }


  public static void main(String argv[]){
    RtspDate testdate=new RtspDate(new Date());
      System.out.println("\nDate : "+testdate.weekday+", "+testdate.GMTDate);
  }

}
