Here you can find the source of formatDateTimeForSolr(Date d)
public static String formatDateTimeForSolr(Date d)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static final String DATE_PATTERN = "yyyy-MM-dd"; public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static final String DATETIME_PATTERN_SOLR = "yyyy-MM-dd'T'HH:mm:ss'Z'"; public static String formatDateTimeForSolr(Date d) { return formatDateTime(d, DATETIME_PATTERN_SOLR); }//from w ww. j a v a 2 s . co m public static String formatDateTimeForSolr(String d) { return formatDateTime(parseDate(d), DATETIME_PATTERN_SOLR); } public static String formatDateTime(Date d) { return formatDateTime(d, DATETIME_PATTERN); } public static String formatDateTime(Date d, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(d); } public static Date parseDate(String str) { return parseDateTime(str, DATE_PATTERN); } public static Date parseDateTime(String str) { return parseDateTime(str, DATETIME_PATTERN); } public static Date parseDateTime(String str, String pattern) { Date d = null; SimpleDateFormat sdf = new SimpleDateFormat(pattern); try { d = sdf.parse(str); } catch (ParseException e) { e.printStackTrace(); } return d; } }