本文整理汇总了Java中org.apache.solr.common.util.DateUtil.getThreadLocalDateFormat方法的典型用法代码示例。如果您正苦于以下问题:Java DateUtil.getThreadLocalDateFormat方法的具体用法?Java DateUtil.getThreadLocalDateFormat怎么用?Java DateUtil.getThreadLocalDateFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.common.util.DateUtil
的用法示例。
在下文中一共展示了DateUtil.getThreadLocalDateFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformValue
import org.apache.solr.common.util.DateUtil; //导入方法依赖的package包/类
/**
* Can be used to transform input values based on their {@link org.apache.solr.schema.SchemaField}
* <p/>
* This implementation only formats dates using the {@link org.apache.solr.common.util.DateUtil}.
*
* @param val The value to transform
* @param schFld The {@link org.apache.solr.schema.SchemaField}
* @return The potentially new value.
*/
protected String transformValue(String val, SchemaField schFld) {
String result = val;
if (schFld != null && schFld.getType() instanceof DateField) {
//try to transform the date
try {
Date date = DateUtil.parseDate(val, dateFormats);
DateFormat df = DateUtil.getThreadLocalDateFormat();
result = df.format(date);
} catch (Exception e) {
// Let the specific fieldType handle errors
// throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Invalid value: " + val + " for field: " + schFld, e);
}
}
return result;
}
示例2: format
import org.apache.solr.common.util.DateUtil; //导入方法依赖的package包/类
private static String format(Date date) {
DateFormat dv = DateUtil.getThreadLocalDateFormat();
return dv.format(date);
}
示例3: format
import org.apache.solr.common.util.DateUtil; //导入方法依赖的package包/类
public static String format(Date date) {
DateFormat dv = DateUtil.getThreadLocalDateFormat();
return dv.format(date).replace("-", "");
}
示例4: getThreadLocalDateFormat
import org.apache.solr.common.util.DateUtil; //导入方法依赖的package包/类
/**
* Returns a formatter that can be use by the current thread if needed to
* convert Date objects to the Internal representation.
*
* @deprecated use {@link org.apache.solr.common.util.DateUtil#getThreadLocalDateFormat()}
*/
@Deprecated
public static DateFormat getThreadLocalDateFormat() {
return DateUtil.getThreadLocalDateFormat();
}