当前位置: 首页>>代码示例>>Java>>正文


Java FastDateFormat类代码示例

本文整理汇总了Java中org.apache.commons.lang3.time.FastDateFormat的典型用法代码示例。如果您正苦于以下问题:Java FastDateFormat类的具体用法?Java FastDateFormat怎么用?Java FastDateFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FastDateFormat类属于org.apache.commons.lang3.time包,在下文中一共展示了FastDateFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: coerceParsedTokens

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
private static Object[] coerceParsedTokens(
        String line, Object[] tokens, boolean safe,
        StructType schema, List<FastDateFormat> dateFormats)  throws Exception {

    Object[] result = new Object[tokens.length];
    for (int i = 0; i < tokens.length; i++) {
        try {
            tokens[i] = !schema.apply(i).dataType().simpleString().equalsIgnoreCase("String") ? tokens[i].toString().trim() : tokens[i];
            result[i] = TypeCast.inputValue(tokens[i].toString(), schema.apply(i).dataType(),
                    schema.apply(i).nullable(), "null", true, dateFormats.get(i));
        } catch (Exception exception) {
            result[i] = null;
            if (!safe) {
                throw new RuntimeException(getSafeMessage(tokens[i], i, schema) + "\n Line being parsed => " + line,exception);
            }
        }
    }
    tokens = result;
    return tokens;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:21,代码来源:DelimitedAndFixedWidthHelper.java

示例2: init

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
static void init(final Configuration configuration) {
	StringCast.datetimeFormat = configuration.getString(
			"common.column.datetimeFormat", StringCast.datetimeFormat);
	StringCast.dateFormat = configuration.getString(
			"common.column.dateFormat", StringCast.dateFormat);
	StringCast.timeFormat = configuration.getString(
			"common.column.timeFormat", StringCast.timeFormat);
	StringCast.extraFormats = configuration.getList(
			"common.column.extraFormats", Collections.<String>emptyList(), String.class);

	StringCast.timeZone = configuration.getString("common.column.timeZone",
			StringCast.timeZone);
	StringCast.timeZoner = TimeZone.getTimeZone(StringCast.timeZone);

	StringCast.datetimeFormatter = FastDateFormat.getInstance(
			StringCast.datetimeFormat, StringCast.timeZoner);
	StringCast.dateFormatter = FastDateFormat.getInstance(
			StringCast.dateFormat, StringCast.timeZoner);
	StringCast.timeFormatter = FastDateFormat.getInstance(
			StringCast.timeFormat, StringCast.timeZoner);

	StringCast.encoding = configuration.getString("common.column.encoding",
			StringCast.encoding);
}
 
开发者ID:yaogdu,项目名称:datax,代码行数:25,代码来源:ColumnCast.java

示例3: backUp

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
public static void backUp(ExportRowMap exportRowMap) {
	// 按照终端过滤,不同的终端写不同的文件
	Map<String, Object> data = exportRowMap.getData();
	String sn = StrUtils.valueOf(data.get("sn"));
	if (StringUtils.isEmpty(sn)) {
		return;
	}
	File termBackupFile = new File(TERMINAL_BACKUP_PATH + sn);
	String timeStr = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:sss").format(new Date());
	String rowMapStr = exportRowMap.toString();
	String result = new StringBuilder().append(timeStr).append(" ").append(rowMapStr).append("\n").toString();
	try {
		FileUtils.write(termBackupFile, result, Charset.defaultCharset(), true);
	} catch (IOException e) {
		log.error(e.getMessage(), e);
		log.info(result);
	}
}
 
开发者ID:songxin1990,项目名称:maxwell-sink,代码行数:19,代码来源:LogUtil.java

示例4: setup

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
@Before
public void setup() {
  this.slf4jLogger = mock(org.slf4j.Logger.class);

  // Use a special GSON configuration that throws exceptions at the right time for the test.
  this.gson = new GsonBuilder().registerTypeAdapterFactory(new TestTypeAdapterFactory()).create();

  this.formatter = FastDateFormat.getInstance(dateFormatString);

  logger = new StandardJsonLogger(slf4jLogger, formatter, gson, null, null, null) {
    @Override
    public void log() {
      logMessage = formatMessage("INFO");
    }

  };
}
 
开发者ID:savoirtech,项目名称:slf4j-json-logger,代码行数:18,代码来源:StandardJsonLoggerExceptionTest.java

示例5: filterByDate

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
/**
 * Default String contains filter processing.
 *
 * @param item          Photo to consider for inclusion.
 * @param filterProperty Filter property name used to determine which photo field to compare with.
 * @param filterValue    Value of the filter.
 * @return True if photo should be included in the resultant list to display.
 */
protected boolean filterByDate(T item, String filterProperty, Object filterValue) {
	FastDateFormat dateInstance = FastDateFormat.getInstance(MM_DD_YY_PATTERN);

	try {
		Object fieldValue = PropertyUtils.getNestedProperty(item, filterProperty);
		Date theDate = (Date) fieldValue;
		String dateStr = dateInstance.format((Date) fieldValue);

		if (filterValue == null || (dateInstance.format((Date) fieldValue).contains(filterValue.toString()))) {
			return true;
		}
	} catch (Exception e) {
		log.error("Failed to filter. ", e);
	}

	return false;
}
 
开发者ID:heather92115,项目名称:photosOpen,代码行数:26,代码来源:DataListFilter.java

示例6: convertTest

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
@Test
public void convertTest() {

	Date now = new Date();
	String source = now.toString();
	System.out.println(source);

	FastDateFormat chinaDate = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
	FastDateFormat sourceDate = FastDateFormat.getInstance("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);

	try {
		Date object = sourceDate.parse(source);
		System.out.println(object);

		String format = chinaDate.format(object);
		System.out.println(format);

	} catch (ParseException e) {
		e.printStackTrace();
	}
}
 
开发者ID:KayuraTeam,项目名称:kayura-activiti,代码行数:22,代码来源:DateTimeFormatTest.java

示例7: formatDate

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
public String formatDate(Date date) {

        if (date == null) {
            return "";
        }

        String fmt = "yyyy/MM/dd HH:mm";
        Locale locale = Locale.JAPANESE;

        // i18nはJavascript側でやる
        //        RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
        //        if (requestAttributes instanceof ServletRequestAttributes) {
        //            HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
        //            String lang = request.getHeader("Accept-Language");
        //            if (StringUtils.indexOfIgnoreCase(lang, "ja") != 0) {
        //                fmt = "d MMM yyyy HH:mm z";
        //                locale = Locale.ENGLISH;
        //            }
        //        }

        FastDateFormat sdf = FastDateFormat.getInstance(fmt, AppConfig.JST, locale);
        String ret = sdf.format(date);
        return ret;
    }
 
开发者ID:af-not-found,项目名称:blog-java2,代码行数:25,代码来源:MyFunction.java

示例8: getAsObject

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
/**
 * @{inheritDoc
 */
@Override
public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value) {
    try {
        FastDateFormat fmt = DF;
        if (preferencesBean != null) {
            fmt = preferencesBean.getDateTimeFormat();
        }
        return fmt.parseObject(value);
    } catch (ParseException e) {
        // throw new IllegalArgumentException("Passed in value was not a valid date format in the pattern of " +
        // PATTERN);
        LOG.error("Cannot parse date value of" + value + ". Must be in the pattern of " + PATTERN);
    }
    return null;
}
 
开发者ID:intuit,项目名称:Tank,代码行数:19,代码来源:DateConverter.java

示例9: ActJobNodeBean

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
public ActJobNodeBean(JobInstance job, boolean hasRights, FastDateFormat fmt) {
    super();
    this.setHasRights(hasRights);
    this.setName(job.getName());
    this.setJobId(String.valueOf(job.getId()));
    this.setId(String.valueOf(job.getId()));
    this.setReportMode(job.getReportingMode().toString());
    this.setStatus(job.getStatus().toString());
    this.setRegion("");
    this.setActiveUsers(String.valueOf(job.getBaselineVirtualUsers()));
    this.setTotalUsers(String.valueOf(job.getTotalVirtualUsers()));
    this.jobDetails = job.getJobDetails();

    if (job.getStartTime() != null) {
        this.setStartTime(fmt.format(job.getStartTime()));
    } else {
        this.setStartTime("");
    }

    if (job.getEndTime() != null) {
        this.setEndTime(fmt.format(job.getEndTime()));
    } else {
        this.setEndTime("");
    }

}
 
开发者ID:intuit,项目名称:Tank,代码行数:27,代码来源:ActJobNodeBean.java

示例10: testAddJob_1

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
/**
 * Run the void addJob(ActJobNodeBean) method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 12/15/14 3:54 PM
 */
@Test
public void testAddJob_1()
    throws Exception {
    Project project = new Project();
    project.setName("");
    ProjectNodeBean fixture = new ProjectNodeBean(project);
    fixture.setJobBeans(new LinkedList());
    ActJobNodeBean jobNode = new ActJobNodeBean(new JobInstance(), true, FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));

    fixture.addJob(jobNode);

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: com_cenqua_clover/CoverageRecorder
    //       at com.intuit.tank.project.Project.<init>(Project.java:77)
}
 
开发者ID:intuit,项目名称:Tank,代码行数:23,代码来源:ProjectNodeBeanTest.java

示例11: testActJobNodeBean_1

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
/**
 * Run the ActJobNodeBean(JobInstance,boolean) constructor test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 12/15/14 3:52 PM
 */
@Test
public void testActJobNodeBean_1()
    throws Exception {
    Workload workload = new Workload();
    workload.setJobConfiguration(new JobConfiguration());
    JobInstance job = new JobInstance(workload, "");
    job.setEndTime(new Date());
    job.setJobDetails("");
    job.setTotalVirtualUsers(1);
    job.setStatus(JobQueueStatus.Aborted);
    job.setStartTime(new Date());
    boolean hasRights = true;

    ActJobNodeBean result = new ActJobNodeBean(job, hasRights, FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: com_cenqua_clover/CoverageRecorder
    //       at com.intuit.tank.api.enumerated.IncrementStrategy.<init>(IncrementStrategy.java:23)
    //       at com.intuit.tank.api.enumerated.IncrementStrategy.<clinit>(IncrementStrategy.java:13)
    //       at com.intuit.tank.project.BaseJob.<init>(BaseJob.java:28)
    //       at com.intuit.tank.project.JobConfiguration.<init>(JobConfiguration.java:63)
    //       at com.intuit.tank.project.Workload.<init>(Workload.java:57)
    assertNotNull(result);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:32,代码来源:ActJobNodeBeanTest.java

示例12: testActJobNodeBean_2

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
/**
 * Run the ActJobNodeBean(String,CloudVmStatusContainer) constructor test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 12/15/14 3:52 PM
 */
@Test
public void testActJobNodeBean_2()
    throws Exception {
    String jobId = "";
    CloudVmStatusContainer container = new CloudVmStatusContainer();
    container.setStatus(JobQueueStatus.Aborted);
    container.setEndTime(new Date());
    container.setStartTime(new Date());

    ActJobNodeBean result = new ActJobNodeBean(jobId, container, FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: com_cenqua_clover/CoverageRecorder
    //       at com.intuit.tank.api.model.v1.cloud.CloudVmStatusContainer.<init>(CloudVmStatusContainer.java:79)
    assertNotNull(result);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:24,代码来源:ActJobNodeBeanTest.java

示例13: testGetJobDetails_1

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
/**
 * Run the String getJobDetails() method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 12/15/14 3:52 PM
 */
@Test
public void testGetJobDetails_1()
    throws Exception {
    Workload workload = new Workload();
    workload.setJobConfiguration(new JobConfiguration());
    JobInstance jobInstance = new JobInstance(workload, "");
    jobInstance.setEndTime(new Date());
    jobInstance.setJobDetails("");
    jobInstance.setTotalVirtualUsers(1);
    jobInstance.setStatus(JobQueueStatus.Aborted);
    jobInstance.setStartTime(new Date());
    ActJobNodeBean fixture = new ActJobNodeBean(jobInstance, true, FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));
    fixture.setVmBeans(new LinkedList());

    String result = fixture.getJobDetails();

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.IncrementStrategy
    //       at com.intuit.tank.project.BaseJob.<init>(BaseJob.java:28)
    //       at com.intuit.tank.project.JobConfiguration.<init>(JobConfiguration.java:63)
    //       at com.intuit.tank.project.Workload.<init>(Workload.java:57)
    assertNotNull(result);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:31,代码来源:ActJobNodeBeanTest.java

示例14: testGetSubNodes_1

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
/**
 * Run the List<VMNodeBean> getSubNodes() method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 12/15/14 3:52 PM
 */
@Test
public void testGetSubNodes_1()
    throws Exception {
    Workload workload = new Workload();
    workload.setJobConfiguration(new JobConfiguration());
    JobInstance jobInstance = new JobInstance(workload, "");
    jobInstance.setEndTime(new Date());
    jobInstance.setJobDetails("");
    jobInstance.setTotalVirtualUsers(1);
    jobInstance.setStatus(JobQueueStatus.Aborted);
    jobInstance.setStartTime(new Date());
    ActJobNodeBean fixture = new ActJobNodeBean(jobInstance, true, FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));
    fixture.setVmBeans(new LinkedList());

    List<VMNodeBean> result = fixture.getSubNodes();

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.IncrementStrategy
    //       at com.intuit.tank.project.BaseJob.<init>(BaseJob.java:28)
    //       at com.intuit.tank.project.JobConfiguration.<init>(JobConfiguration.java:63)
    //       at com.intuit.tank.project.Workload.<init>(Workload.java:57)
    assertNotNull(result);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:31,代码来源:ActJobNodeBeanTest.java

示例15: testGetType_1

import org.apache.commons.lang3.time.FastDateFormat; //导入依赖的package包/类
/**
 * Run the String getType() method test.
 *
 * @throws Exception
 *
 * @generatedBy CodePro at 12/15/14 3:52 PM
 */
@Test
public void testGetType_1()
    throws Exception {
    Workload workload = new Workload();
    workload.setJobConfiguration(new JobConfiguration());
    JobInstance jobInstance = new JobInstance(workload, "");
    jobInstance.setEndTime(new Date());
    jobInstance.setJobDetails("");
    jobInstance.setTotalVirtualUsers(1);
    jobInstance.setStatus(JobQueueStatus.Aborted);
    jobInstance.setStartTime(new Date());
    ActJobNodeBean fixture = new ActJobNodeBean(jobInstance, true, FastDateFormat.getDateTimeInstance(FastDateFormat.MEDIUM, FastDateFormat.MEDIUM));
    fixture.setVmBeans(new LinkedList());

    String result = fixture.getType();

    // An unexpected exception was thrown in user code while executing this test:
    //    java.lang.NoClassDefFoundError: Could not initialize class com.intuit.tank.api.enumerated.IncrementStrategy
    //       at com.intuit.tank.project.BaseJob.<init>(BaseJob.java:28)
    //       at com.intuit.tank.project.JobConfiguration.<init>(JobConfiguration.java:63)
    //       at com.intuit.tank.project.Workload.<init>(Workload.java:57)
    assertNotNull(result);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:31,代码来源:ActJobNodeBeanTest.java


注:本文中的org.apache.commons.lang3.time.FastDateFormat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。