当前位置: 首页>>代码示例>>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;未经允许,请勿转载。