當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。