Java 类org.apache.commons.lang.time.FastDateFormat 实例源码

项目:metl    文件:AboutPanel.java   
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++);
}
项目:metl    文件:ModelAttributeScriptHelper.java   
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 "";
    }
}
项目:wtf-core    文件:BaseListener.java   
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()));
    }
  }
}
项目:flume-release-1.7.0    文件:TimeBasedIndexNameBuilder.java   
@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);
}
项目:hadoop    文件:ClusterSummarizer.java   
@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));
  }
}
项目:aliyun-oss-hadoop-fs    文件:RollingLevelDB.java   
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());
}
项目:aliyun-oss-hadoop-fs    文件:ClusterSummarizer.java   
@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));
  }
}
项目:big-c    文件:ClusterSummarizer.java   
@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));
  }
}
项目:mongoose-base    文件:RangeDefinedDateFormattingSupplier.java   
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);
}
项目:mongoose-base    文件:AsyncRangeDefinedDateFormattingSupplier.java   
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
    );
}
项目:netty-http-3.x    文件:StaticActionDispatcher.java   
@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()));
}
项目:olap-access    文件:BaseItem.java   
/**
 * 构建显示日期
 * 
 * @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);
        }
    }
}
项目:olap-access    文件:OlapDriverImpl.java   
/**
 * 构造时间条件
 * 
 * @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("\'");
}
项目:flume-ng-elasticsearch5-sink    文件:TimeBasedIndexNameBuilder.java   
@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);
}
项目:flume-ng-audit-db    文件:TimeBasedIndexNameBuilder.java   
@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);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ClusterSummarizer.java   
@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));
  }
}
项目:ElasticsearchSink2    文件:TimeBasedIndexNameBuilder.java   
@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);
}
项目:example-java    文件:DateFormatExample.java   
@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);
}
项目:hadoop-plus    文件:ClusterSummarizer.java   
@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));
  }
}
项目:Portofino    文件:ActivityItem.java   
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);
}
项目:hops    文件:RollingLevelDB.java   
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());
}
项目:hops    文件:ClusterSummarizer.java   
@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));
  }
}
项目:metl    文件:ModelAttributeScriptHelper.java   
private String formatdate(String pattern, Date value) {
    FastDateFormat formatter = FastDateFormat.getInstance(pattern);
    if (value != null) {
        return formatter.format(value);
    } else {
        return null;
    }
}
项目:metl    文件:Stamp.java   
@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);

}
项目:wtf-core    文件:XmlJuintReport.java   
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);
  }
}
项目:wtf-core    文件:BaseLogger.java   
public static void LOG(Level level, String message) {
  String levelType = level != null ? level.toString() : WTFConst.EMPTY_STRING;

  stdout = stdout == null ? System.out : stdout;

  // shortern the log level names.
  levelType = levelType == Level.WARNING.toString() ? WTFConst.LOG_LEVEL_WARN : levelType;
  levelType = levelType == Level.SEVERE.toString() ? WTFConst.LOG_LEVEL_ERROR : levelType;

  if (level != null) {
    String logMessage =
        String.format("%s %s  %s",
                      FastDateFormat.getInstance(
                          WTFConst.DATA_FORMAT_HH_MM_SS_SSS).format(new Date()),
                      levelType, message);

    stdout.println(logMessage);

    // Store only when this feature is enabled.
    if (true) {
      long threadID = Thread.currentThread().getId();
      StringBuilder log = logsByThreadID.get(threadID);
      if (null == log) {
        log = new StringBuilder();
        logsByThreadID.put(threadID, log);
      }
      log.append(logMessage);
      //  This is a StringBuilder, so we need to add the newlines ourselves.
      log.append(WTFConst.NEW_LINE);

      // Log a copy for WTF dash.
      // TODO (Venkat)
      //WTFDashThreadPoolSafeLogger.pushLogs(logMessage);
    }

  } else {
    stdout.println(WTFConst.EMPTY_STRING);
  }
}
项目:hadoop-TCP    文件:ClusterSummarizer.java   
@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));
  }
}
项目:BB-BigData-Log-Tools    文件:DateFormatter.java   
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);
  }
}
项目:nocket    文件:TouchedListenerModelWrapper.java   
/**
 * 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);
}
项目:hardfs    文件:ClusterSummarizer.java   
@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));
  }
}
项目:hadoop-on-lustre2    文件:ClusterSummarizer.java   
@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));
  }
}
项目:tesora-dve-pub    文件:Emitter.java   
public String emitConstantExprValue(IConstantExpression expr, Object value) {
    boolean needsQuoting = false;
    String any = null;
    if (expr instanceof ILiteralExpression) {
        ILiteralExpression ile = (ILiteralExpression) expr;
        if (ile.getCharsetHint() != null)
            any = ile.getCharsetHint().getUnquotedName().get();
        needsQuoting = ile.isStringLiteral();
    } else if (expr instanceof LateBindingConstantExpression) {
        LateBindingConstantExpression lbce = (LateBindingConstantExpression) expr;
        final Type lbtype = lbce.getType();
        if (lbtype.isStringType() || lbtype.isTimestampType())
            needsQuoting = true;
    }
    String tok = null;
    if (value instanceof String) {
        tok = (String) value;
    } else if (value instanceof Date) {
        tok = FastDateFormat.getInstance(MysqlNativeConstants.MYSQL_TIMESTAMP_FORMAT).format((Date) value);
    } else {
        tok = String.valueOf(value);
    }
    if (value != null && needsQuoting) {
        tok = "'" + tok + "'";
    }
    if (any != null) return any + tok;
    return tok;
}
项目:tesora-dve-pub    文件:DBTypeBasedUtilsTest.java   
@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);
        }
    }       
}
项目:ingestion    文件:TimeBasedIndexNameBuilder.java   
@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);
}
项目:flume-elasticsearch    文件:LogstashEventSerializerIndexRequestBuilderFactory.java   
@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"));
    }
}
项目:hadoop-logdriver    文件:DateFormatter.java   
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);
  }
}
项目:logmate    文件:DateFormatHelper.java   
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);
}
项目:flume-release-1.7.0    文件:EventSerializerIndexRequestBuilderFactory.java   
protected EventSerializerIndexRequestBuilderFactory(
    ElasticSearchEventSerializer serializer, FastDateFormat fdf) {
  super(fdf);
  this.serializer = serializer;
}
项目:flume-release-1.7.0    文件:TimeBasedIndexNameBuilder.java   
@VisibleForTesting
FastDateFormat getFastDateFormat() {
  return fastDateFormat;
}
项目:stage-job    文件:XxlJobServiceImpl.java   
@Override
public ReturnT<Map<String, Object>> triggerChartDate() {
    Date from = DateUtils.addDays(new Date(), -30);
    Date to = new Date();

    List<String> triggerDayList = new ArrayList<String>();
    List<Integer> triggerDayCountSucList = new ArrayList<Integer>();
    List<Integer> triggerDayCountFailList = new ArrayList<Integer>();
    int triggerCountSucTotal = 0;
    int triggerCountFailTotal = 0;

    List<Map<String, Object>> triggerCountMapAll = xxlJobLogDao.triggerCountByDay(from, to, -1);
    List<Map<String, Object>> triggerCountMapSuc = xxlJobLogDao.triggerCountByDay(from, to, ReturnT.SUCCESS_CODE);
    if (CollectionUtils.isNotEmpty(triggerCountMapAll)) {
        for (Map<String, Object> item: triggerCountMapAll) {
            String day = String.valueOf(item.get("triggerDay"));
            int dayAllCount = Integer.valueOf(String.valueOf(item.get("triggerCount")));
            int daySucCount = 0;
            int dayFailCount = dayAllCount - daySucCount;

            if (CollectionUtils.isNotEmpty(triggerCountMapSuc)) {
                for (Map<String, Object> sucItem: triggerCountMapSuc) {
                    String daySuc = String.valueOf(sucItem.get("triggerDay"));
                    if (day.equals(daySuc)) {
                        daySucCount = Integer.valueOf(String.valueOf(sucItem.get("triggerCount")));
                        dayFailCount = dayAllCount - daySucCount;
                    }
                }
            }

            triggerDayList.add(day);
            triggerDayCountSucList.add(daySucCount);
            triggerDayCountFailList.add(dayFailCount);
            triggerCountSucTotal += daySucCount;
            triggerCountFailTotal += dayFailCount;
        }
    } else {
           for (int i = 4; i > -1; i--) {
               triggerDayList.add(FastDateFormat.getInstance("yyyy-MM-dd").format(DateUtils.addDays(new Date(), -i)));
               triggerDayCountSucList.add(0);
               triggerDayCountFailList.add(0);
           }
    }

    Map<String, Object> result = new HashMap<String, Object>();
    result.put("triggerDayList", triggerDayList);
    result.put("triggerDayCountSucList", triggerDayCountSucList);
    result.put("triggerDayCountFailList", triggerDayCountFailList);
    result.put("triggerCountSucTotal", triggerCountSucTotal);
    result.put("triggerCountFailTotal", triggerCountFailTotal);
    return new ReturnT<Map<String, Object>>(result);
}