// Path: openbahn-api/src/de/marcusschiesser/dbpendler/server/utils/DateUtils.java
// public class DateUtils {
// 	
// 	public static Date unifyDateTime(Date date, Date time) {
// 		Calendar calendar = getCalendar();
// 		calendar.setTime(date);
// 		Calendar timeCalender = getCalendar();
// 		timeCalender.setTime(time);
// 		calendar.set(Calendar.HOUR_OF_DAY, timeCalender.get(Calendar.HOUR_OF_DAY));
// 		calendar.set(Calendar.MINUTE, timeCalender.get(Calendar.MINUTE));
// 		calendar.set(Calendar.SECOND, timeCalender.get(Calendar.SECOND));
// 		return calendar.getTime();
// 	}
// 	
// 	public static Calendar getCalendar() {
// 		// should be fine for date calculations as bahn.de operates in GERMANY
// 		return Calendar.getInstance(Locale.GERMANY);
// 	}
// 	
// 	public static Date getThisMonday() {
// 		Calendar calendar = getCalendar();
// 		calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
// 		String date = getDateFormat().format(calendar.getTime());
// 		try {
// 			return getDateFormat().parse(date);
// 		} catch (ParseException e) {
// 			// should never ever be called.
// 			e.printStackTrace();
// 			return null;
// 		}
// 	}
// 	
// 	public static Date addMinutes(Date date, int minutes) {
// 		Calendar calendar = getCalendar();
// 		calendar.setTime(date);
// 		calendar.add(Calendar.MINUTE, minutes);
// 		return calendar.getTime();
// 	}
// 
// 
// 	public static Date addDay(Date date, int days) {
// 		Calendar calendar = getCalendar();
// 		calendar.setTime(date);
// 		calendar.add(Calendar.DATE, days);
// 		return calendar.getTime();
// 	}
// 
// 	public static DateFormat getTimeFormat() {
// 		return new SimpleDateFormat("HH:mm");
// 	}
// 
// 	public static DateFormat getDateFormat() {
// 		return new SimpleDateFormat("dd.MM.yyyy");
// 	}
// }


import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import de.marcusschiesser.dbpendler.server.utils.DateUtils;

	@Override
	public void startElement(String uri, String localName, String qName,
	        Attributes attributes) throws SAXException {
	
	        if (localName.equalsIgnoreCase("td")
	                && "overview timelink".equalsIgnoreCase(attributes.getValue("class"))) {
	            insideTimelink = 1;
	        }
	        if (localName.equalsIgnoreCase("td")
	                && "overview iphonepfeil".equalsIgnoreCase(attributes.getValue("class"))) {
	            insidePrice = 1;
	        }
	        if (insideTimelink > 0 && "a".equalsIgnoreCase(localName)) {
	            anchors.add(attributes.getValue("href"));
	        }
		
	}
	
	@Override
	public void endElement(String uri, String localName, String qName)
			throws SAXException {
		if(localName.equalsIgnoreCase("td")) {
			if(insideTimelink>0) insideTimelink = 0;
			if(insidePrice>0) insidePrice = 0;
		}
	}
	
	@Override
	public void characters(char[] ch, int start, int length)
			throws SAXException {

// Path: openbahn-api/src/de/marcusschiesser/dbpendler/server/utils/DateUtils.java
// public class DateUtils {
// 	
// 	public static Date unifyDateTime(Date date, Date time) {
// 		Calendar calendar = getCalendar();
// 		calendar.setTime(date);
// 		Calendar timeCalender = getCalendar();
// 		timeCalender.setTime(time);
// 		calendar.set(Calendar.HOUR_OF_DAY, timeCalender.get(Calendar.HOUR_OF_DAY));
// 		calendar.set(Calendar.MINUTE, timeCalender.get(Calendar.MINUTE));
// 		calendar.set(Calendar.SECOND, timeCalender.get(Calendar.SECOND));
// 		return calendar.getTime();
// 	}
// 	
// 	public static Calendar getCalendar() {
// 		// should be fine for date calculations as bahn.de operates in GERMANY
// 		return Calendar.getInstance(Locale.GERMANY);
// 	}
// 	
// 	public static Date getThisMonday() {
// 		Calendar calendar = getCalendar();
// 		calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
// 		String date = getDateFormat().format(calendar.getTime());
// 		try {
// 			return getDateFormat().parse(date);
// 		} catch (ParseException e) {
// 			// should never ever be called.
// 			e.printStackTrace();
// 			return null;
// 		}
// 	}
// 	
// 	public static Date addMinutes(Date date, int minutes) {
// 		Calendar calendar = getCalendar();
// 		calendar.setTime(date);
// 		calendar.add(Calendar.MINUTE, minutes);
// 		return calendar.getTime();
// 	}
// 
// 
// 	public static Date addDay(Date date, int days) {
// 		Calendar calendar = getCalendar();
// 		calendar.setTime(date);
// 		calendar.add(Calendar.DATE, days);
// 		return calendar.getTime();
// 	}
// 
// 	public static DateFormat getTimeFormat() {
// 		return new SimpleDateFormat("HH:mm");
// 	}
// 
// 	public static DateFormat getDateFormat() {
// 		return new SimpleDateFormat("dd.MM.yyyy");
// 	}
// }


// Path: openbahn-api/src/de/marcusschiesser/dbpendler/server/bahnwrapper/handler/TimeExtractionHandler.java
import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import de.marcusschiesser.dbpendler.server.utils.DateUtils;

	@Override
	public void startElement(String uri, String localName, String qName,
	        Attributes attributes) throws SAXException {
	
	        if (localName.equalsIgnoreCase("td")
	                && "overview timelink".equalsIgnoreCase(attributes.getValue("class"))) {
	            insideTimelink = 1;
	        }
	        if (localName.equalsIgnoreCase("td")
	                && "overview iphonepfeil".equalsIgnoreCase(attributes.getValue("class"))) {
	            insidePrice = 1;
	        }
	        if (insideTimelink > 0 && "a".equalsIgnoreCase(localName)) {
	            anchors.add(attributes.getValue("href"));
	        }
		
	}
	
	@Override
	public void endElement(String uri, String localName, String qName)
			throws SAXException {
		if(localName.equalsIgnoreCase("td")) {
			if(insideTimelink>0) insideTimelink = 0;
			if(insidePrice>0) insidePrice = 0;
		}
	}
	
	@Override
	public void characters(char[] ch, int start, int length)
			throws SAXException {

		String s = new String(ch);
