本文整理汇总了Java中org.apache.commons.lang3.time.FastDateFormat.format方法的典型用法代码示例。如果您正苦于以下问题:Java FastDateFormat.format方法的具体用法?Java FastDateFormat.format怎么用?Java FastDateFormat.format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.time.FastDateFormat
的用法示例。
在下文中一共展示了FastDateFormat.format方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterByDate
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
/**
* Default String contains filter processing.
*
* @param item Photo to consider for inclusion.
* @param filterProperty Filter property name used to determine which photo field to compare with.
* @param filterValue Value of the filter.
* @return True if photo should be included in the resultant list to display.
*/
protected boolean filterByDate(T item, String filterProperty, Object filterValue) {
FastDateFormat dateInstance = FastDateFormat.getInstance(MM_DD_YY_PATTERN);
try {
Object fieldValue = PropertyUtils.getNestedProperty(item, filterProperty);
Date theDate = (Date) fieldValue;
String dateStr = dateInstance.format((Date) fieldValue);
if (filterValue == null || (dateInstance.format((Date) fieldValue).contains(filterValue.toString()))) {
return true;
}
} catch (Exception e) {
log.error("Failed to filter. ", e);
}
return false;
}
示例2: convertTest
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
@Test
public void convertTest() {
Date now = new Date();
String source = now.toString();
System.out.println(source);
FastDateFormat chinaDate = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
FastDateFormat sourceDate = FastDateFormat.getInstance("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
try {
Date object = sourceDate.parse(source);
System.out.println(object);
String format = chinaDate.format(object);
System.out.println(format);
} catch (ParseException e) {
e.printStackTrace();
}
}
示例3: formatDate
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
public String formatDate(Date date) {
if (date == null) {
return "";
}
String fmt = "yyyy/MM/dd HH:mm";
Locale locale = Locale.JAPANESE;
// i18nはJavascript側でやる
// RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// if (requestAttributes instanceof ServletRequestAttributes) {
// HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
// String lang = request.getHeader("Accept-Language");
// if (StringUtils.indexOfIgnoreCase(lang, "ja") != 0) {
// fmt = "d MMM yyyy HH:mm z";
// locale = Locale.ENGLISH;
// }
// }
FastDateFormat sdf = FastDateFormat.getInstance(fmt, AppConfig.JST, locale);
String ret = sdf.format(date);
return ret;
}
示例4: testFormats
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
@Test
public void testFormats() throws Exception {
Date instant = myDateInstantParser.parse("2001-02-03 13:01:02.555");
for (FastDateFormat next : BaseDateTimeDt.getFormatters()) {
Calendar cal = Calendar.getInstance();
cal.setTime(instant);
String value = next.format(cal);
ourLog.info("String: {}", value);
DateTimeDt dt = new DateTimeDt(value);
String reEncoded = next.format(dt.getValue());
assertEquals(value, reEncoded);
}
}
示例5: CachingDateFormatter
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
public CachingDateFormatter(FastDateFormat fastDateFormat) {
this.fastDateFormat = fastDateFormat;
onSecond = fastDateFormat.getPattern().indexOf("SSS") == -1;
long current = System.currentTimeMillis();
this.cachedTime = new AtomicReference<CachedTime>(new CachedTime(current, fastDateFormat.format(current)));
}
示例6: formatLongTime
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
public String formatLongTime(long time) {
String fmt = "yyyy/MM/dd HH:mm:ss.SSS";
Locale locale = Locale.JAPANESE;
FastDateFormat sdf = FastDateFormat.getInstance(fmt, AppConfig.JST, locale);
String ret = sdf.format(new Date(time));
return ret;
}
示例7: formatPubDate
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
public String formatPubDate(Date date) {
if (date == null) {
return "";
}
String fmt = "EEE, dd MMM yyyy HH:mm:ss Z";
Locale locale = Locale.ENGLISH;
FastDateFormat sdf = FastDateFormat.getInstance(fmt, AppConfig.JST, locale);
String ret = sdf.format(date);
return ret;
}
示例8: getAsString
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
/**
* @{inheritDoc
*/
@Override
public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object obj) {
FastDateFormat fmt = DF;
if (preferencesBean != null) {
fmt = preferencesBean.getDateTimeFormat();
}
return fmt.format(obj);
}
示例9: DateDiffLabel
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
public DateDiffLabel(Date date1, Date date2, boolean isVertical) {
super("", JLabel.CENTER);
this.date1 = date1;
this.date2 = date2;
String text = I18N.getMsgColon("msg.pref.datediff") + " " + getDays();
FastDateFormat fdf = FastDateFormat
.getDateInstance(FastDateFormat.SHORT);
String dateStr1 = fdf.format(date1);
String dateStr2 = fdf.format(date2);
String text2 = "(" + dateStr1 + " - " + dateStr2 + ")";
setText(getDays() + " " + text2);
setToolTipText("<html>" + text + "<br>" + text2);
setIcon(I18N.getIcon("icon.small.datediff"));
}
示例10: convert2yyyy_MM_dd_HH_mm_ss
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
public static String convert2yyyy_MM_dd_HH_mm_ss(long dateMillionSeconds) {
Date dateTime = new Date(dateMillionSeconds);
FastDateFormat formatter = YYYY_MM_DD_HH_MM_SS;
return formatter.format(dateTime);
}
示例11: convert2yyyy_MM_dd_HH_mm
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
public static String convert2yyyy_MM_dd_HH_mm(long dateMillionSeconds) {
Date dateTime = new Date(dateMillionSeconds);
FastDateFormat formatter = YYYY_MM_DD_HH_MM;
return formatter.format(dateTime);
}
示例12: convert2yyyy_MM_dd
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
public static String convert2yyyy_MM_dd(long dateMillionSeconds) {
Date dateTime = new Date(dateMillionSeconds);
FastDateFormat formatter = YYYY_MM_DD;
return formatter.format(dateTime);
}
示例13: convert2yyyy_MM_dd_china
import org.apache.commons.lang3.time.FastDateFormat; //导入方法依赖的package包/类
public static String convert2yyyy_MM_dd_china(long dateMillionSeconds) {
Date dateTime = new Date(dateMillionSeconds);
FastDateFormat formatter = yyyy年MM月dd日;
return formatter.format(dateTime);
}