本文整理汇总了Java中org.apache.commons.lang.time.FastDateFormat类的典型用法代码示例。如果您正苦于以下问题:Java FastDateFormat类的具体用法?Java FastDateFormat怎么用?Java FastDateFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FastDateFormat类属于org.apache.commons.lang.time包,在下文中一共展示了FastDateFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import org.apache.commons.lang.time.FastDateFormat; //导入依赖的package包/类
protected void refresh() {
table.removeAllItems();
int itemId = 0;
table.addItem(new Object[] { "Application Version", VersionUtils.getCurrentVersion() },
itemId++);
table.addItem(new Object[] { "Build Time", VersionUtils.getBuildTime() }, itemId++);
table.addItem(new Object[] { "SCM Revision", VersionUtils.getScmVersion() }, itemId++);
table.addItem(new Object[] { "SCM Branch", VersionUtils.getScmBranch() }, itemId++);
table.addItem(new Object[] { "Host Name", AppUtils.getHostName() }, itemId++);
table.addItem(new Object[] { "IP Address", AppUtils.getIpAddress() }, itemId++);
table.addItem(new Object[] { "Java Version", System.getProperty("java.version") },
itemId++);
table.addItem(
new Object[] { "System Time",
FastDateFormat.getTimeInstance(FastDateFormat.MEDIUM).format(new Date()) },
itemId++);
table.addItem(
new Object[] { "Used Heap", Long.toString(
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) },
itemId++);
table.addItem(new Object[] { "Heap Size", Long.toString(Runtime.getRuntime().maxMemory()) },
itemId++);
table.addItem(new Object[] { "Last Restart",
CommonUiUtils.formatDateTime(AgentManager.lastRestartTime) }, itemId++);
}
示例2: 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 "";
}
}
示例3: Init
import org.apache.commons.lang.time.FastDateFormat; //导入依赖的package包/类
public synchronized void Init(ISuite suite) {
if (runId == null) {
String stepGuid = System.getProperty("stepguid");
if (stepGuid != null && !stepGuid.isEmpty()) {
BaseListener.runId = String.format("%s", stepGuid);
} else {
String tsGuid = System.getProperty("tsguid");
if (tsGuid == null || stepGuid.isEmpty()) {
tsGuid = suite.getName().replace(" ", "_");
}
//SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd_MMMMM_yyyy_hh_mm_aaa");
BaseListener.runId =
String.format("%s_%s", tsGuid,
FastDateFormat.getInstance("dd_MMMMM_yyyy_hh_mm_aaa").format(new Date()));
}
}
}
示例4: 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);
}
示例5: update
import org.apache.commons.lang.time.FastDateFormat; //导入依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public void update(ClusterStats item) {
try {
numBlacklistedTrackers = item.getStatus().getBlacklistedTrackers();
numActiveTrackers = item.getStatus().getTaskTrackers();
maxMapTasks = item.getStatus().getMaxMapTasks();
maxReduceTasks = item.getStatus().getMaxReduceTasks();
} catch (Exception e) {
long time = System.currentTimeMillis();
LOG.info("Error in processing cluster status at "
+ FastDateFormat.getInstance().format(time));
}
}
示例6: 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());
}
示例7: 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);
}
示例8: 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
);
}
示例9: 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()));
}
示例10: buildShowDate
import org.apache.commons.lang.time.FastDateFormat; //导入依赖的package包/类
/**
* 构建显示日期
*
* @param timeUnit
* @param dayFormat
* @since 2015-7-28 by wangchongjie
*/
protected void buildShowDate(int timeUnit, FastDateFormat dayFormat) {
if (this.unixTime > 0) {
Date d = new Date();
d.setTime(this.unixTime * 1000L);
if (OlapConstants.TU_DAY == timeUnit) { // 天粒度
this.showDate = dayFormat.format(d);
} else if (OlapConstants.TU_HOUR == timeUnit) {
this.showDate = sd3.format(d);
} else {
this.showDate = dayFormat.format(d);
}
}
}
示例11: 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("\'");
}
示例12: 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);
}
示例13: ActivityItem
import org.apache.commons.lang.time.FastDateFormat; //导入依赖的package包/类
public ActivityItem(Locale locale, Date timestamp, String imageSrc, String imageHref, String imageAlt, String message, String key) {
this.locale = locale;
this.timestamp = timestamp;
this.imageSrc = imageSrc;
this.imageHref = imageHref;
this.imageAlt = imageAlt;
this.message = message;
this.key = key;
dateFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL, locale);
}
示例14: handle
import org.apache.commons.lang.time.FastDateFormat; //导入依赖的package包/类
@Override
public void handle(Message inputMessage, ISendMessageCallback callback, boolean unitOfWorkBoundaryReached) {
String stampType = properties.get(STAMP_TYPE);
String messageHeaderKey = properties.get(HEADER_NAME_TO_USE);
Serializable messageHeaderValue = null;
if (TYPE_FIRST_ENTITY_ATTRIBUTE.equals(stampType) && inputMessage instanceof EntityDataMessage) {
EntityDataMessage message = (EntityDataMessage) inputMessage;
ArrayList<EntityData> payload = message.getPayload();
String attributeId = properties.get(ENTITY_COLUMN);
for (EntityData entityData : payload) {
messageHeaderValue = (Serializable) entityData.get(attributeId);
if (messageHeaderValue != null) {
break;
}
}
} else if (TYPE_TIMESTAMP.equals(stampType)) {
messageHeaderValue = new Date();
} else if (TYPE_TIMESTAMP_STRING_1.equals(stampType)) {
messageHeaderValue = FastDateFormat.getInstance(TYPE_TIMESTAMP_STRING_1).format(new Date());
} else if (TYPE_TIMESTAMP_STRING_2.equals(stampType)) {
messageHeaderValue = FastDateFormat.getInstance(TYPE_TIMESTAMP_STRING_2).format(new Date());
}
Map<String, Serializable> messageHeaders = new HashMap<>();
messageHeaders.put(messageHeaderKey, messageHeaderValue);
callback.forward(messageHeaders, inputMessage);
}
示例15: createElement
import org.apache.commons.lang.time.FastDateFormat; //导入依赖的package包/类
public static void createElement(XMLStringBuffer doc, ITestResult tr) {
Properties attrs = new Properties();
long elapsedTimeMillis = tr.getEndMillis() - tr.getStartMillis();
String name =
tr.getMethod().isTest() ? tr.getName() : Utils.detailedMethodName(tr.getMethod(), false);
//SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMMMM hh:mm aaa");
//String testRunTest = String.format("%s", simpleDateFormat.format(new Date()));
String testRunTest = FastDateFormat.getInstance("dd-MMMMM hh:mm aaa").format(new Date());
attrs.setProperty(XMLConstants.ATTR_NAME, String.format("%s [%s]", name, testRunTest));
attrs.setProperty(XMLConstants.ATTR_CLASSNAME, tr.getTestClass().getRealClass().getName());
attrs.setProperty(XMLConstants.ATTR_TIME, "" + (((double) elapsedTimeMillis) / 1000));
if((ITestResult.FAILURE == tr.getStatus()) || (ITestResult.SKIP == tr.getStatus())) {
doc.push(XMLConstants.TESTCASE, attrs);
if(ITestResult.FAILURE == tr.getStatus()) {
createFailureElement(doc, tr);
}
else if(ITestResult.SKIP == tr.getStatus()) {
createSkipElement(doc, tr);
}
doc.pop();
}else {
doc.addEmptyElement(XMLConstants.TESTCASE, attrs);
}
}