• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FmtDate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getProcessors

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
public static CellProcessor[] getProcessors(List<String> fields) {

		int fieldsSize = fields.size();
		final CellProcessor[] processors = new CellProcessor[fieldsSize];
		int i = 0;
		for(String field : fields){
			if(Arrays.asList(processorsDateType).contains(field)){
				processors[i] =  new Optional(new FmtDate("dd-MM-yyyy HH:mm"));
			}else{
				processors[i] = new ConvertNullTo("");
			}
			i++;
		}

		return processors;
	}
 
开发者ID:EsupPortail,项目名称:esup-sgc,代码行数:17,代码来源:ImportExportService.java


示例2: getProcessor

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
/**
 * Returns array of cellprocessors, one for each field
 */
private CellProcessor[] getProcessor(List<Field> fields)
{
  CellProcessor[] processor = new CellProcessor[fields.size()];
  int fieldCount = 0;
  for (Field field : fields) {
    if (field.getType() == FieldType.DATE) {
      String format = field.getConstraints().get(DelimitedSchema.DATE_FORMAT) == null ? null
          : (String)field.getConstraints().get(DelimitedSchema.DATE_FORMAT);
      processor[fieldCount++] = new Optional(new FmtDate(format == null ? "dd/MM/yyyy" : format));
    } else {
      processor[fieldCount++] = new Optional();
    }
  }
  return processor;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:19,代码来源:CsvFormatter.java


示例3: writeCsv

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
public static <V> void writeCsv(final DataFrame<V> df, final OutputStream output)
throws IOException {
    try (CsvListWriter writer = new CsvListWriter(new OutputStreamWriter(output), CsvPreference.STANDARD_PREFERENCE)) {
        final String[] header = new String[df.size()];
        final Iterator<Object> it = df.columns().iterator();
        for (int c = 0; c < df.size(); c++) {
            header[c] = String.valueOf(it.hasNext() ? it.next() : c);
        }
        writer.writeHeader(header);
        final CellProcessor[] procs = new CellProcessor[df.size()];
        final List<Class<?>> types = df.types();
        for (int c = 0; c < df.size(); c++) {
            final Class<?> cls = types.get(c);
            if (Date.class.isAssignableFrom(cls)) {
                procs[c] = new ConvertNullTo("", new FmtDate("yyyy-MM-dd'T'HH:mm:ssXXX"));
            } else {
                procs[c] = new ConvertNullTo("");
            }
        }
        for (final List<V> row : df) {
            writer.write(row, procs);
        }
    }
}
 
开发者ID:cardillo,项目名称:joinery,代码行数:25,代码来源:Serialization.java


示例4: getProcessors

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
/**
 * Sets up the processors used for the examples. There are 10 CSV columns, so 10 processors are defined. All values
 * are converted to Strings before writing (there's no need to convert them), and null values will be written as
 * empty columns (no need to convert them to "").
 * 
 * @return the cell processors
 */
private static CellProcessor[] getProcessors() {
	
	final CellProcessor[] processors = new CellProcessor[] { new UniqueHashCode(), // customerNo (must be unique)
		new NotNull(), // firstName
		new NotNull(), // lastName
		new FmtDate("dd/MM/yyyy"), // birthDate
		new NotNull(), // mailingAddress
		new Optional(new FmtBool("Y", "N")), // married
		new Optional(), // numberOfKids
		new NotNull(), // favouriteQuote
		new NotNull(), // email
		new LMinMax(0L, LMinMax.MAX_LONG) // loyaltyPoints
	};
	
	return processors;
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:24,代码来源:Writing.java


示例5: testDateSupport

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
@Test
public void testDateSupport() throws IOException {
	Calendar calendar = Calendar.getInstance();
	calendar.set(Calendar.YEAR, 1999);
	calendar.set(Calendar.MONTH, 6);
	calendar.set(Calendar.DAY_OF_MONTH, 12);
	
	FeatureBean character = new FeatureBean("John", "Connor", 16);
	character.setBirthDate(calendar.getTime());
	
	String[] mapping = { "birthDate" };
	DecimalFormat formatter = new DecimalFormat();
	formatter.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance());
	CellProcessor[] processors = { new FmtDate("yyyy-MM-dd") };
	
	StringWriter writer = new StringWriter();
	CsvBeanWriter beanWriter = new CsvBeanWriter(writer, STANDARD_PREFERENCE);
	beanWriter.write(character, mapping, processors);
	beanWriter.close();
	
	String csv = writer.toString();
	Assert.assertNotNull(csv);
	Assert.assertEquals("1999-07-12\r\n", csv);
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:25,代码来源:WritingFeaturesTest.java


示例6: testRowLineNumberCorrectness

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
/**
 * Test that row/line numbers reported during exception are determined correctly
 * 
 * @throws IOException
 * @throws SQLException
 */
@Test(expected = SuperCsvCellProcessorException.class)
public void testRowLineNumberCorrectness() throws SQLException, IOException {
	final int LINE_NUMBER = 5;
	final int ROW_NUMBER = 4;
	final Object[][] causesException = { { "1", "Alexander\r\nGraham", date(1945, 6, 13), },
		{ "2", "Bob", date(1919, 2, 25), }, { "3", "Alice", "CAUSES EXCEPTION", },
		{ "4", "Bill", date(1973, 7, 10), }, { "5", "Miranda", date(1999, 1, 3), }, };
	final String[] headers = { "customerNo", "firstName", "birthDate" };
	final ResultSet resultSet = new ResultSetMock(causesException, headers);
	final CellProcessor[] cellProcessors = { null, null, new FmtDate("dd/MM/yyyy") };
	try {
		csvResultSetWriter.write(resultSet, cellProcessors);
	}
	catch(SuperCsvCellProcessorException e) {
		final int actualLineNumber = e.getCsvContext().getLineNumber();
		final int actualRowNumber = e.getCsvContext().getRowNumber();
		assertEquals("line number not correct", LINE_NUMBER, actualLineNumber);
		assertEquals("row number not correct", ROW_NUMBER, actualRowNumber);
		throw e;
	}
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:28,代码来源:CsvResultSetWriterTest.java


示例7: getProcessors

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
private static CellProcessor[] getProcessors() {

		final CellProcessor[] processors = new CellProcessor[] {
				null,
				null,
				null,
				null,
				null,
				null,
				null,
				null,
				new Optional(new FmtDate("dd/MM/yyyy - HH:mm")),
				new Optional(new FmtDate("dd/MM/yyyy - HH:mm")),
				null,
				new Optional(new FmtDate("dd/MM/yyyy - HH:mm"))
		};

		return processors;
	}
 
开发者ID:EsupPortail,项目名称:esup-dematec,代码行数:20,代码来源:CsvService.java


示例8: testConvertsToBasicObjects

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
@Test
public void testConvertsToBasicObjects() throws IOException {
	Calendar calendar = Calendar.getInstance();
	calendar.set(Calendar.YEAR, 1999);
	calendar.set(Calendar.MONTH, 6);
	calendar.set(Calendar.DAY_OF_MONTH, 12);
	
	FeatureBean character = new FeatureBean("John", "Connor", 16);
	character.setSavings(new BigDecimal(6.65));
	character.setBirthDate(calendar.getTime());
	
	String[] mapping = { "lastName", "firstName", "age", "birthDate", "savings" };
	DecimalFormat formatter = new DecimalFormat();
	formatter.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance());
	CellProcessor[] processors = { new NotNull(), new NotNull(), new NotNull(), new FmtDate("yyyy-MM-dd"),
		new FmtNumber(formatter) };
	
	StringWriter writer = new StringWriter();
	CsvPreference customPreference = new Builder('"', '|', "\r\n").build();
	CsvBeanWriter beanWriter = new CsvBeanWriter(writer, customPreference);
	beanWriter.write(character, mapping, processors);
	beanWriter.close();
	
	String csv = writer.toString();
	Assert.assertNotNull(csv);
	Assert.assertEquals("Connor|John|16|1999-07-12|" + formatter.format(character.getSavings()) + "\r\n", csv);
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:28,代码来源:WritingFeaturesTest.java


示例9: testConverterSupport

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
@Test
public void testConverterSupport() throws IOException {
	Calendar calendar = Calendar.getInstance();
	calendar.set(Calendar.YEAR, 1999);
	calendar.set(Calendar.MONTH, 6);
	calendar.set(Calendar.DAY_OF_MONTH, 12);
	
	FeatureBean character = new FeatureBean("John", "Connor", 16);
	character.setSavings(new BigDecimal(6.65));
	character.setBirthDate(calendar.getTime());
	
	String[] mapping = { "lastName", "firstName", "age", "birthDate", "savings" };
	DecimalFormat formatter = new DecimalFormat();
	formatter.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance());
	CellProcessor[] processors = { new NotNull(), new NotNull(), new NotNull(), new FmtDate("yyyy-MM-dd"),
		new FmtNumber(formatter) };
	
	StringWriter writer = new StringWriter();
	CsvPreference customPreference = new Builder('"', '|', "\r\n").build();
	CsvBeanWriter beanWriter = new CsvBeanWriter(writer, customPreference);
	beanWriter.write(character, mapping, processors);
	beanWriter.close();
	
	String csv = writer.toString();
	Assert.assertNotNull(csv);
	Assert.assertEquals("Connor|John|16|1999-07-12|" + formatter.format(character.getSavings()) + "\r\n", csv);
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:28,代码来源:WritingFeaturesTest.java


示例10: getProcessors

import org.supercsv.cellprocessor.FmtDate; //导入依赖的package包/类
private static CellProcessor[] getProcessors() {

		final CellProcessor[] processors = new CellProcessor[] { 
				new UniqueHashCode(), // id (must be unique)
				new NotNull(), // filename
				new FmtDate("dd/MM/yyyy - HH:mm"), // sendTime
				new NotNull(), // owner
		};

		return processors;
	}
 
开发者ID:EsupPortail,项目名称:esup-dematec,代码行数:12,代码来源:ArchiveService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ErrorReporter类代码示例发布时间:2022-05-23
下一篇:
Java TripleCollection类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap