package de.tblsoft.solr.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
	
	public static String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
	
	public static String date2String(Date date) {
		SimpleDateFormat sdfPipeline = new SimpleDateFormat(
				"yyyy-MM-dd'T'HH:mm:ssZ");
		return sdfPipeline.format(date);

	}
	
	public static Date getDate(String date) {
		SimpleDateFormat sdfPipeline = new SimpleDateFormat(
				"yyyy-MM-dd'T'HH:mm:ssZ");
		try {
			return sdfPipeline.parse(date);
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
	}
	
	public static String date2String(Date date, String format) {
		SimpleDateFormat sdfPipeline = new SimpleDateFormat(
				format);
		return sdfPipeline.format(date);

	}
	
	public static Date getDate(String date, String format) {
		SimpleDateFormat sdfPipeline = new SimpleDateFormat(
				format);
		try {
			return sdfPipeline.parse(date);
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
		
	}

}

@@ -24,16 +24,174 @@
 .util;%0A%0A
+import org.joda.time.DateTime;%0Aimport org.joda.time.DateTimeZone;%0Aimport org.joda.time.format.DateTimeFormat;%0Aimport org.joda.time.format.DateTimeFormatter;%0A%0A
 import j
@@ -215,16 +215,16 @@
 eption;%0A
-
 import j
@@ -363,17 +363,86 @@
 m:ssZ%22;%0A
-%09
+%0A%09public static String SOLR_DATE_FORMAT = %22yyyy-MM-dd'T'HH:mm:ss'Z'%22;%0A
 %0A%09public
@@ -1270,10 +1270,247 @@
 %0A%09%09%0A%09%7D%0A%0A
+%09public static String toSolrDate(String date) %7B%0A%09%09DateTime jodaDate = new DateTime(date);%0A%09%09DateTimeFormatter formatter = DateTimeFormat.forPattern(SOLR_DATE_FORMAT).withZone(DateTimeZone.UTC);%0A%09%09return jodaDate.toString(formatter);%0A%09%7D%0A%0A
 %7D%0A

add a new method to transform date objects to solr date