当前位置: 首页>>代码示例>>Java>>正文


Java FastDateFormat.format方法代码示例

本文整理汇总了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;
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:26,代码来源:DataListFilter.java

示例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();
	}
}
 
开发者ID:KayuraTeam,项目名称:kayura-activiti,代码行数:22,代码来源:DateTimeFormatTest.java

示例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;
    }
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:25,代码来源:MyFunction.java

示例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);

	}
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:18,代码来源:BaseDateTimeDtTest.java

示例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)));
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:8,代码来源:CachingDateFormatter.java

示例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;
    }
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:10,代码来源:MyFunction.java

示例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;
    }
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:14,代码来源:MyFunction.java

示例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);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:12,代码来源:DateConverter.java

示例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"));
}
 
开发者ID:markkohdev,项目名称:oStorybook,代码行数:15,代码来源:DateDiffLabel.java

示例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);
}
 
开发者ID:vsona,项目名称:RxJava2RetrofitDemo,代码行数:6,代码来源:DateUtils.java

示例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);
}
 
开发者ID:vsona,项目名称:RxJava2RetrofitDemo,代码行数:6,代码来源:DateUtils.java

示例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);
}
 
开发者ID:vsona,项目名称:RxJava2RetrofitDemo,代码行数:6,代码来源:DateUtils.java

示例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);
}
 
开发者ID:vsona,项目名称:RxJava2RetrofitDemo,代码行数:6,代码来源:DateUtils.java


注:本文中的org.apache.commons.lang3.time.FastDateFormat.format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。