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


Java FastDateFormat類代碼示例

本文整理匯總了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++);
}
 
開發者ID:JumpMind,項目名稱:metl,代碼行數:27,代碼來源:AboutPanel.java

示例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 "";
    }
}
 
開發者ID:JumpMind,項目名稱:metl,代碼行數:17,代碼來源:ModelAttributeScriptHelper.java

示例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()));
    }
  }
}
 
開發者ID:web-auto,項目名稱:wtf-core,代碼行數:19,代碼來源:BaseListener.java

示例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);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:15,代碼來源:TimeBasedIndexNameBuilder.java

示例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));
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:15,代碼來源:ClusterSummarizer.java

示例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());
}
 
開發者ID:aliyun-beta,項目名稱:aliyun-oss-hadoop-fs,代碼行數:12,代碼來源:RollingLevelDB.java

示例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);
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:8,代碼來源:RangeDefinedDateFormattingSupplier.java

示例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
	);
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:12,代碼來源:AsyncRangeDefinedDateFormattingSupplier.java

示例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()));
}
 
開發者ID:iceize,項目名稱:netty-http-3.x,代碼行數:33,代碼來源:StaticActionDispatcher.java

示例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);
        }
    }
}
 
開發者ID:wangchongjie,項目名稱:olap-access,代碼行數:21,代碼來源:BaseItem.java

示例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("\'");
}
 
開發者ID:wangchongjie,項目名稱:olap-access,代碼行數:17,代碼來源:OlapDriverImpl.java

示例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);
}
 
開發者ID:sunlin901203,項目名稱:example-java,代碼行數:12,代碼來源:DateFormatExample.java

示例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);
}
 
開發者ID:ManyDesigns,項目名稱:Portofino,代碼行數:12,代碼來源:ActivityItem.java

示例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);

}
 
開發者ID:JumpMind,項目名稱:metl,代碼行數:30,代碼來源:Stamp.java

示例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);
  }
}
 
開發者ID:web-auto,項目名稱:wtf-core,代碼行數:30,代碼來源:XmlJuintReport.java


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