本文整理匯總了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 "";
}
}
示例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);
}
示例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());
}
示例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);
}
示例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
);
}
示例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()));
}
示例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("\'");
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例14: CustomElasticSearchIndexRequestBuilderFactory
import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
public CustomElasticSearchIndexRequestBuilderFactory() {
super(FastDateFormat.getInstance("HH_mm_ss_SSS",
TimeZone.getTimeZone("EST5EDT")));
}
示例15: DateEncoder
import org.apache.commons.lang.time.FastDateFormat; //導入方法依賴的package包/類
public DateEncoder(String format, TimeZone timeZone) {
this.dateFormat = FastDateFormat.getInstance(format, timeZone);
}