LuceneDateFieldFormat (索引查询日期格式处理)

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

public class LuceneDateFieldFormat {
    public static String foramtDateToString(String dateStr) throws ParseException {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d = formatter.parse(dateStr);
        SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMddHHmmss");
        return formatter1.format(d);
    }
}

猜你喜欢

转载自blog.csdn.net/gongjian0321/article/details/88957128