Example usage for org.apache.commons.lang.time FastDateFormat getInstance

List of usage examples for org.apache.commons.lang.time FastDateFormat getInstance

Introduction

In this page you can find the example usage for org.apache.commons.lang.time FastDateFormat getInstance.

Prototype

public static FastDateFormat getInstance(String pattern, Locale locale) 

Source Link

Document

Gets a formatter instance using the specified pattern and locale.

Usage

From source file:com.intuit.tank.PreferencesBean.java

/**
 * //from   w  w  w .j  a v a2s .com
 */
public PreferencesBean() {
    dateTimeFotmat = FastDateFormat.getInstance(TankConstants.DATE_FORMAT_WITH_TIMEZONE, clientTimeZone);
    timestampFormat = FastDateFormat.getInstance(preferredTimeStampFormat);
}

From source file:net.logstash.logback.composite.FormattedTimestampJsonProvider.java

@Override
public void start() {
    formatter = FastDateFormat.getInstance(pattern, timeZone);
    super.start();
}

From source file:com.tango.logstash.flume.elasticsearch.sink.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"));
    }/*from   w w w  .  j  a  va  2 s.com*/
}

From source file:com.gigya.flume.TestElasticSearchIndexRequestBuilderFactory.java

void initDefaults() {
    timestampedIndexName = DEFAULT_INDEX_NAME + '-'
            + ElasticSearchIndexRequestBuilderFactory.df.format(FIXED_TIME_MILLIS);
    dateFormat = FastDateFormat.getInstance("yyyy.MM.dd", TimeZone.getTimeZone("Etc/UTC"));
}

From source file:com.intuit.tank.PreferencesBean.java

/**
 * @param clientTimeZone// w  w w  .  j ava2s.  com
 *            the clientTimeZone to set
 */
public void setClientTimeZone(TimeZone clientTimeZone) {
    this.clientTimeZone = clientTimeZone;
    dateTimeFotmat = FastDateFormat.getInstance(TankConstants.DATE_FORMAT, clientTimeZone);
}

From source file:com.eluup.flume.sink.elasticsearch.TimeBasedIndexNameBuilder.java

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;
    }/*from  w  w w.  j a va  2s  . co m*/
    if (StringUtils.isBlank(timeZoneString)) {
        timeZoneString = DEFAULT_TIME_ZONE;
    }
    fastDateFormat = FastDateFormat.getInstance(dateFormatString, TimeZone.getTimeZone(timeZoneString));
    indexPrefix = context.getString(ElasticSearchSinkConstants.INDEX_NAME);
}

From source file:ch.cern.db.flume.sink.elasticsearch.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;
    }// ww w  .  jav  a2  s. co  m
    if (StringUtils.isBlank(timeZoneString)) {
        timeZoneString = DEFAULT_TIME_ZONE;
    }
    fastDateFormat = FastDateFormat.getInstance(dateFormatString, TimeZone.getTimeZone(timeZoneString));
    indexPrefix = context.getString(ElasticSearchSinkConstants.INDEX_NAME);
}

From source file:hudson.plugins.timestamper.format.TimestampFormatterImpl.java

/**
 * Create a new {@link TimestampFormatterImpl}.
 * /*from www .j a va 2  s .c o  m*/
 * @param systemTimeFormat
 *          the system clock time format
 * @param elapsedTimeFormat
 *          the elapsed time format
 * @param timeZoneId
 *          the configured time zone identifier
 * @param request
 *          the current HTTP request
 */
public TimestampFormatterImpl(String systemTimeFormat, String elapsedTimeFormat, Optional<String> timeZoneId,
        HttpServletRequest request) {

    String cookieValue = null;
    Cookie[] cookies = request.getCookies();
    if (cookies != null) {
        for (Cookie cookie : cookies) {
            if ("jenkins-timestamper".equals(cookie.getName())) {
                cookieValue = cookie.getValue();
                break;
            }
        }
    }

    if ("elapsed".equalsIgnoreCase(cookieValue)) {
        formatTimestamp = new ElapsedTimeFormatFunction(elapsedTimeFormat);
    } else if ("none".equalsIgnoreCase(cookieValue)) {
        formatTimestamp = new EmptyFormatFunction();
    } else {
        // "system", no cookie, or unrecognised cookie
        TimeZone timeZone = null;
        if (timeZoneId.isPresent()) {
            timeZone = TimeZone.getTimeZone(timeZoneId.get());
        }
        FastDateFormat format = FastDateFormat.getInstance(systemTimeFormat, timeZone);
        formatTimestamp = new SystemTimeFormatFunction(format);
    }
}

From source file:net.logstash.logback.LogstashAbstractFormatter.java

private FastDateFormat createFastDateFormat(TimeZone timeZone) {
    return FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSSZZ", timeZone);
}

From source file:fr.cls.atoll.motu.library.misc.netcdf.NetCdfReader.java

/**
 * Returns a GMT string representation (yyyy-MM-dd HH:mm:ss) from a date value and an udunits string.
 * //from www. ja v a 2  s  . c  o m
 * @param unitsString udunits string
 * @param value value of the date
 * 
 * @return a string representation of the date
 * 
 * @throws MotuException the motu exception
 */
public static String getDateAsGMTString(double value, String unitsString) throws MotuException {

    Date date = NetCdfReader.getDate(value, unitsString);

    return FastDateFormat.getInstance(DATETIME_FORMAT, GMT_TIMEZONE).format(date);
    // return GMTDateFormat.TO_STRING_DEFAULT.format(date);
    // return DateFormat.getInstance().format(date);
}