當前位置: 首頁>>代碼示例>>Java>>正文


Java FastDateFormat.getInstance方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.time.FastDateFormat.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java FastDateFormat.getInstance方法的具體用法?Java FastDateFormat.getInstance怎麽用?Java FastDateFormat.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.time.FastDateFormat的用法示例。


在下文中一共展示了FastDateFormat.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: formatdate

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
public String formatdate(String pattern) {
    FastDateFormat formatter = FastDateFormat.getInstance(pattern);
    if (value instanceof Date) {
        return formatter.format((Date) value);
    } else if (value != null) {
        String text = value != null ? value.toString() : "";
        Date dateToParse = parseDateFromText(pattern, text);
        if (dateToParse != null) {
            return formatter.format((Date) value);
        } else {
            return "Not a datetime";
        }
    } else {
        return "";
    }
}
 
開發者ID:JumpMind,項目名稱:metl,代碼行數:17,代碼來源:ModelAttributeScriptHelper.java

示例2: configure

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
@Override
public void configure(Context context) {
  String dateFormatString = context.getString(DATE_FORMAT);
  String timeZoneString = context.getString(TIME_ZONE);
  if (StringUtils.isBlank(dateFormatString)) {
    dateFormatString = DEFAULT_DATE_FORMAT;
  }
  if (StringUtils.isBlank(timeZoneString)) {
    timeZoneString = DEFAULT_TIME_ZONE;
  }
  fastDateFormat = FastDateFormat.getInstance(dateFormatString,
      TimeZone.getTimeZone(timeZoneString));
  indexPrefix = context.getString(ElasticSearchSinkConstants.INDEX_NAME);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:15,代碼來源:TimeBasedIndexNameBuilder.java

示例3: initRollingPeriod

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
protected synchronized void initRollingPeriod() {
  final String lcRollingPeriod = conf.get(
      YarnConfiguration.TIMELINE_SERVICE_ROLLING_PERIOD,
      YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ROLLING_PERIOD);
  this.rollingPeriod = RollingPeriod.valueOf(lcRollingPeriod
      .toUpperCase(Locale.ENGLISH));
  fdf = FastDateFormat.getInstance(rollingPeriod.dateFormat(),
      TimeZone.getTimeZone("GMT"));
  sdf = new SimpleDateFormat(rollingPeriod.dateFormat());
  sdf.setTimeZone(fdf.getTimeZone());
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:12,代碼來源:RollingLevelDB.java

示例4: RangeDefinedDateFormattingSupplier

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
public RangeDefinedDateFormattingSupplier(
	final long seed, final Date startDate, final Date endDate, final String formatStr
) {
	super(seed, startDate.getTime(), endDate.getTime());
	format = formatStr == null || formatStr.isEmpty() ?
		null : FastDateFormat.getInstance(formatStr);
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:8,代碼來源:RangeDefinedDateFormattingSupplier.java

示例5: AsyncRangeDefinedDateFormattingSupplier

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
public AsyncRangeDefinedDateFormattingSupplier(
	final CoroutinesProcessor coroutinesProcessor,
	final long seed, final Date minValue, final Date maxValue, final String formatString
) throws OmgDoesNotPerformException {
	super(coroutinesProcessor, seed, minValue, maxValue);
	this.format = formatString == null || formatString.isEmpty() ?
		null : FastDateFormat.getInstance(formatString);
	longGenerator = new AsyncRangeDefinedLongFormattingSupplier(
		coroutinesProcessor, seed, minValue.getTime(), maxValue.getTime(), null
	);
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:12,代碼來源:AsyncRangeDefinedDateFormattingSupplier.java

示例6: dispatch

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
@Override
public void dispatch(ChannelHandlerContext context, Action action, Request request, Response response) {
	StaticAction staticAction = (StaticAction) action;

	if (staticAction.contents() == null) {
		response.status = HttpResponseStatus.MOVED_PERMANENTLY;
		response.headers.put(HttpHeaders.Names.LOCATION, new Header(HttpHeaders.Names.LOCATION, staticAction.path() + Context.PATH_DELIMITER));
	}

	if (!settings.isCache()) {
		response.output = staticAction.contents();
		response.contentType = Context.getContentType(staticAction.path());
		return;
	}

	if (needCache(request, staticAction)) {
		response.status = HttpResponseStatus.NOT_MODIFIED;
		response.header(HttpHeaders.Names.DATE, FastDateFormat.getInstance(HTTP_DATE_FORMAT, TimeZone.getTimeZone("GMT"), Locale.US).format(Calendar.getInstance()));
		return;
	}

	response.output = staticAction.contents();
	response.contentType = Context.getContentType(staticAction.path());

	Calendar calendar = Calendar.getInstance();
	FastDateFormat dateFormat = FastDateFormat.getInstance(HTTP_DATE_FORMAT, TimeZone.getTimeZone("GMT"), Locale.US);
	response.header(HttpHeaders.Names.DATE, dateFormat.format(calendar));
	calendar.add(Calendar.SECOND, settings.getCacheTtl());
	response.header(HttpHeaders.Names.EXPIRES, dateFormat.format(calendar));
	response.header(HttpHeaders.Names.CACHE_CONTROL, "private, max-age=" + settings.getCacheTtl());
	response.header(HttpHeaders.Names.LAST_MODIFIED, dateFormat.format(staticAction.timestamp()));
}
 
開發者ID:iceize,項目名稱:netty-http-3.x,代碼行數:33,代碼來源:StaticActionDispatcher.java

示例7: appendDateCondition

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
/**
 * 構造時間條件
 * 
 * @param sql
 * @param request
 * @since 2015-7-28 by wangchongjie
 */
private <T extends ItemAble> void appendDateCondition(StringBuilder sql, OlapRequest<T> request) {
    FastDateFormat f = FastDateFormat.getInstance("yyyy-MM-dd");
    Date startDate = this.getTableStartDateInConf(request);
    Date[] ensuredDate = DateUtils.ensureDate(request.getFrom(), request.getTo(), startDate);

    sql.append(" ").append(olapConfig.dateColumn()).append(" >= \'").append(f.format(ensuredDate[0].getTime()))
       .append("\' AND ").append(olapConfig.dateColumn()).append(" < \'")
       .append(f.format(DateUtils.addDays(ensuredDate[1], 1).getTime())).append("\'");
}
 
開發者ID:wangchongjie,項目名稱:olap-access,代碼行數:17,代碼來源:OlapDriverImpl.java

示例8: main

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
@Test
public  void main() {
    // 使用FastDateFormat
    FastDateFormat format = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
    String dateStr = format.format(new Date());

    // 使用DateFormatUtils,底層還是用的FastDateFormat
    String t = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");
    System.out.println(dateStr);
    System.out.println(t);
}
 
開發者ID:sunlin901203,項目名稱:example-java,代碼行數:12,代碼來源:DateFormatExample.java

示例9: DateFormatter

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
public DateFormatter(String formatString) {
  if ("RFC822".equals(formatString.toUpperCase())) {
    format = FastDateFormat.getInstance(RFC822_FORMAT);
  } else if ("RFC822_SEC_UTC".equals(formatString.toUpperCase())) {
    format = FastDateFormat.getInstance(RFC822_SEC_UTC_FORMAT);
  } else if ("RFC3164".equals(formatString.toUpperCase())) {
    format = FastDateFormat.getInstance(RFC3164_FORMAT);
  } else if ("RFC5424".equals(formatString.toUpperCase())) {
    format = FastDateFormat.getInstance(RFC5424_FORMAT);
  } else {
    format = FastDateFormat.getInstance(formatString);
  }
}
 
開發者ID:blackberry,項目名稱:BB-BigData-Log-Tools,代碼行數:14,代碼來源:DateFormatter.java

示例10: formatDateNullSafe

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
/**
 * Format date null safe.
 *
 * @param format the format
 * @param value the value
 * @return the string
 */
private String formatDateNullSafe(String format, E value) {
    if (value == null) {
        return null;
    }
    FastDateFormat df = FastDateFormat.getInstance(format);
    return df.format(value);
}
 
開發者ID:Nocket,項目名稱:nocket,代碼行數:15,代碼來源:TouchedListenerModelWrapper.java

示例11: mysqlConvertToObjectTest

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
@Test
public void mysqlConvertToObjectTest() throws Exception {
	ColumnMetadata colMd = new ColumnMetadata();
	FastDateFormat fdfDate = FastDateFormat.getInstance(MysqlNativeConstants.MYSQL_DATE_FORMAT);
	FastDateFormat fdfDateTime = FastDateFormat.getInstance(MysqlNativeConstants.MYSQL_DATETIME_FORMAT);
	FastDateFormat fdfTime = FastDateFormat.getInstance(MysqlNativeConstants.MYSQL_TIME_FORMAT);
	FastDateFormat fdfTimestamp = FastDateFormat.getInstance(MysqlNativeConstants.MYSQL_TIMESTAMP_FORMAT);
	
	for (Pair<MyFieldType, Object> expValue : expValuesMysql) {
		DataTypeValueFunc dtvf = DBTypeBasedUtils.getMysqlTypeFunc(expValue.getFirst());
		assertNotNull("Couldn't find function for " + expValue.getFirst(), dtvf);
		if ( expValue.getSecond() != null ) {
			String value;
			if ( MyFieldType.FIELD_TYPE_DATE.equals(expValue.getFirst()) ) {
				value = fdfDate.format(expValue.getSecond());
			} else if ( MyFieldType.FIELD_TYPE_DATETIME.equals(expValue.getFirst()) ) {
					value = fdfDateTime.format(expValue.getSecond());
			} else if ( MyFieldType.FIELD_TYPE_TIME.equals(expValue.getFirst()) ) {
				value = fdfTime.format(expValue.getSecond());
			} else if ( MyFieldType.FIELD_TYPE_TIMESTAMP.equals(expValue.getFirst()) ) {
				value = fdfTimestamp.format(expValue.getSecond());
			} else if (MyFieldType.FIELD_TYPE_BIT.equals(expValue.getFirst())) {
				value = new String((byte[]) expValue.getSecond(), CharsetUtil.ISO_8859_1);
			} else {
				value = expValue.getSecond().toString();
			}
			
			Object valueObj = dtvf.convertStringToObject(value, colMd);
			assertEqualData(expValue.getSecond(), valueObj);
		}
	}		
}
 
開發者ID:Tesora,項目名稱:tesora-dve-pub,代碼行數:33,代碼來源:DBTypeBasedUtilsTest.java

示例12: configure

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
@Override
public void configure(Context context) {
    super.configure(context);

    // Ex: "yyyy-MM-dd"
    String indexFormatStr = context.getString(PARAM_INDEX_FORMAT);
    if (StringUtils.isNotBlank(indexFormatStr)) {
        indexFormater = FastDateFormat.getInstance(indexFormatStr, TimeZone.getTimeZone("Etc/UTC"));
    }
}
 
開發者ID:DevOps-TangoMe,項目名稱:flume-elasticsearch,代碼行數:11,代碼來源:LogstashEventSerializerIndexRequestBuilderFactory.java

示例13: format

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
public String format(Date date) {
	if (null == dateFormatter) {
		if (null == dateFormatPattern) {
			dateFormatPattern = "yyyy-MM-dd HH:mm:ss SSS zz";
		}
		dateFormatter = FastDateFormat.getInstance(dateFormatPattern, null == timezone ? null : TimeZone.getTimeZone(timezone), null);
	}
	return dateFormatter.format(date);
}
 
開發者ID:orctom,項目名稱:logmate,代碼行數:10,代碼來源:DateFormatHelper.java

示例14: CustomElasticSearchIndexRequestBuilderFactory

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
public CustomElasticSearchIndexRequestBuilderFactory() {
  super(FastDateFormat.getInstance("HH_mm_ss_SSS",
      TimeZone.getTimeZone("EST5EDT")));
}
 
開發者ID:Redliver,項目名稱:flume-ng-elasticsearch5-sink,代碼行數:5,代碼來源:TestElasticSearchSink.java

示例15: DateEncoder

import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
public DateEncoder(String format, TimeZone timeZone) {
    this.dateFormat = FastDateFormat.getInstance(format, timeZone);
}
 
開發者ID:dataz,項目名稱:dataz-core,代碼行數:4,代碼來源:DateEncoder.java


注:本文中的org.apache.commons.lang.time.FastDateFormat.getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。