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


Java ParseDate类代码示例

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


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

示例1: getProcessors

import org.supercsv.cellprocessor.ParseDate; //导入依赖的package包/类
/**
 * Sets up the processors used for the examples. There are 10 CSV columns, so 10 processors are defined. Empty
 * columns are read as null (hence the NotNull() for mandatory columns).
 * 
 * @return the cell processors
 */
private static CellProcessor[] getProcessors() {
	
	final String emailRegex = "[a-z0-9\\._][email protected][a-z0-9\\.]+"; // just an example, not very robust!
	StrRegEx.registerMessage(emailRegex, "must be a valid email address");
	
	final CellProcessor[] processors = new CellProcessor[] { new UniqueHashCode(), // customerNo (must be unique)
		new NotNull(), // firstName
		new NotNull(), // lastName
		new ParseDate("dd/MM/yyyy"), // birthDate
		new NotNull(), // mailingAddress
		new Optional(new ParseBool()), // married
		new Optional(new ParseInt()), // numberOfKids
		new NotNull(), // favouriteQuote
		new StrRegEx(emailRegex), // email
		new LMinMax(0L, LMinMax.MAX_LONG) // loyaltyPoints
	};
	
	return processors;
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:26,代码来源:Reading.java

示例2: testConvertsToBasicObjects

import org.supercsv.cellprocessor.ParseDate; //导入依赖的package包/类
@Test
public void testConvertsToBasicObjects() throws Exception {
	String csv = "Connor|John|16|1999-07-12|6" + decimalFormatSymbols.getDecimalSeparator() + "65\r\n";
	String[] mapping = { "lastName", "firstName", "age", "birthDate", "savings" };
	CellProcessor[] processors = { new NotNull(), new NotNull(), new ParseInt(), new ParseDate("yyyy-MM-dd"),
		new ParseBigDecimal(decimalFormatSymbols) };
	
	CsvPreference customPreference = new Builder('"', '|', "\r\n").build();
	CsvBeanReader beanReader = new CsvBeanReader(new StringReader(csv), customPreference);
	FeatureBean character = beanReader.read(FeatureBean.class, mapping, processors);
	
	Assert.assertNotNull(character);
	Assert.assertEquals("John", character.getFirstName());
	Assert.assertEquals("Connor", character.getLastName());
	Assert.assertEquals(16, character.getAge());
	Assert.assertEquals(new SimpleDateFormat("yyyy-MM-dd").parse("1999-07-12"), character.getBirthDate());
	Assert.assertEquals(new BigDecimal(6.65, new MathContext(3)), character.getSavings());
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:19,代码来源:ReadingFeaturesTest.java

示例3: testConverterSupport

import org.supercsv.cellprocessor.ParseDate; //导入依赖的package包/类
@Test
public void testConverterSupport() throws Exception {
	String csv = "Connor|John|16|1999-07-12|6" + decimalFormatSymbols.getDecimalSeparator() + "65\r\n";
	String[] mapping = { "lastName", "firstName", "age", "birthDate", "savings" };
	CellProcessor[] processors = { new NotNull(), new NotNull(), new ParseInt(), new ParseDate("yyyy-MM-dd"),
		new ParseBigDecimal(decimalFormatSymbols) };
	
	CsvPreference customPreference = new Builder('"', '|', "\r\n").build();
	CsvBeanReader beanReader = new CsvBeanReader(new StringReader(csv), customPreference);
	FeatureBean character = beanReader.read(FeatureBean.class, mapping, processors);
	
	Assert.assertNotNull(character);
	Assert.assertEquals("John", character.getFirstName());
	Assert.assertEquals("Connor", character.getLastName());
	Assert.assertEquals(16, character.getAge());
	Assert.assertEquals(new SimpleDateFormat("yyyy-MM-dd").parse("1999-07-12"), character.getBirthDate());
	Assert.assertEquals(new BigDecimal(6.65, new MathContext(3)), character.getSavings());
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:19,代码来源:ReadingFeaturesTest.java

示例4: createTypes

import org.supercsv.cellprocessor.ParseDate; //导入依赖的package包/类
public static void createTypes()
{
	typeHash.put("DECIMAL", new ParseDouble());
	typeHash.put("STRING", new NotNull());
	typeHash.put("DATE", new ParseDate("MM/dd/yyyy"));
	typeHash.put("NUMBER", new ParseInt());
	typeHash.put("BOOLEAN", new ParseBool());
	
	// now the optionals
	typeHash.put("DECIMAL_OPTIONAL", new Optional(new ParseDouble()));
	typeHash.put("STRING_OPTIONAL", new Optional());
	typeHash.put("DATE_OPTIONAL", new Optional(new ParseDate("MM/dd/yyyy")));
	typeHash.put("NUMBER_OPTIONAL", new Optional(new ParseInt()));
	typeHash.put("BOOLEAN_OPTIONAL", new Optional(new ParseBool()));
	
}
 
开发者ID:SEMOSS,项目名称:semoss,代码行数:17,代码来源:CSVReader.java

示例5: initialise

import org.supercsv.cellprocessor.ParseDate; //导入依赖的package包/类
public void initialise(String[] properties, CellProcessor[] processors)
{
  for (int i = 0; i < getFields().size(); i++) {
    FIELD_TYPE type = getFields().get(i).type;
    properties[i] = getFields().get(i).name;
    if (type == FIELD_TYPE.DOUBLE) {
      processors[i] = new Optional(new ParseDouble());
    } else if (type == FIELD_TYPE.INTEGER) {
      processors[i] = new Optional(new ParseInt());
    } else if (type == FIELD_TYPE.FLOAT) {
      processors[i] = new Optional(new ParseDouble());
    } else if (type == FIELD_TYPE.LONG) {
      processors[i] = new Optional(new ParseLong());
    } else if (type == FIELD_TYPE.SHORT) {
      processors[i] = new Optional(new ParseInt());
    } else if (type == FIELD_TYPE.STRING) {
      processors[i] = new Optional();
    } else if (type == FIELD_TYPE.CHARACTER) {
      processors[i] = new Optional(new ParseChar());
    } else if (type == FIELD_TYPE.BOOLEAN) {
      processors[i] = new Optional(new ParseChar());
    } else if (type == FIELD_TYPE.DATE) {
      processors[i] = new Optional(new ParseDate("dd/MM/yyyy"));
    }
  }

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:28,代码来源:AbstractCsvParser.java

示例6: open

import org.supercsv.cellprocessor.ParseDate; //导入依赖的package包/类
/**
 *
 * @param conf
 * @param context
 * @param collector
 */
@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
    
    this.collector = collector;
    CellProcessor[] p = {new Optional(), new Optional(),
        new Optional(new Token(" ", null, new ParseDate("yyyy-MM-dd HH:mm:ss.SSS", true))),
        new Optional(new ParseDouble()), new Optional(new ParseDouble()), new Optional()};
    this.processors = p;
    File[] files = (new File("src/test/resources")).listFiles();
    ComparableFileByModified[] pairs = new ComparableFileByModified[files.length];
    for (int i = 0; i < files.length; i++) {
        pairs[i] = new ComparableFileByModified(files[i]);
    }
    Arrays.sort(pairs);
    this.beanReader = new CsvBeanReader[files.length];
    for (int i = 0; i < pairs.length; i++) {
        try {
            this.beanReader[i] = new CsvBeanReader(new FileReader(pairs[i].f), CsvPreference.STANDARD_PREFERENCE);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(EsperBoltStressTest.class.getName()).log(Level.SEVERE, null, ex);
            this.beanReader[i] = null;
        }
    }
    this.beanReaderCount = 0;
    startMilis = System.currentTimeMillis();
}
 
开发者ID:miguelantonio,项目名称:storm-esper-bolt,代码行数:33,代码来源:EsperBoltStressTest.java

示例7: testDateSupport

import org.supercsv.cellprocessor.ParseDate; //导入依赖的package包/类
@Test
public void testDateSupport() throws Exception {
	String csv = "1999-07-12";
	String[] mapping = { "birthDate" };
	CellProcessor[] processors = { new ParseDate("yyyy-MM-dd") };
	
	CsvBeanReader beanReader = new CsvBeanReader(new StringReader(csv), STANDARD_PREFERENCE);
	FeatureBean character = beanReader.read(FeatureBean.class, mapping, processors);
	
	Assert.assertNotNull(character);
	Assert.assertEquals(new SimpleDateFormat("yyyy-MM-dd").parse("1999-07-12"), character.getBirthDate());
}
 
开发者ID:super-csv,项目名称:super-csv,代码行数:13,代码来源:ReadingFeaturesTest.java

示例8: loadData

import org.supercsv.cellprocessor.ParseDate; //导入依赖的package包/类
/**
 * Call this to load the Data, it uses the CSV files in its classpath
 */
public void loadData() {
	
	startTime = new Date().getTime();
	
	//load the customers
	String[] nameMapping = new String[]{"city","birthday","id","name", "emailAddress"};
	CellProcessor[] processors = new CellProcessor[] { 
       		new NotNull(), //city
       		new ParseDate("dd-MM-yyyy"), //birthday
               new NotNull(), //id
               new NotNull(), //name
               new NotNull() //email
       };
       loadCustomers("customer.csv",nameMapping,processors);
       
       //load the products
       nameMapping = new String[]{"stockOnHand","wholeSalePrice","brand","type", "color", "size", "gender", "id"};
       processors = new CellProcessor[] { 
       		new ParseInt(),//stockOnHand
       		new ParseDouble(),//wholeSalePrice
       		new NotNull(),//brand
       		new NotNull(),//type
       		new NotNull(),//color
       		new ParseDouble(),//size
       		new NotNull(),//gender
               new NotNull()//productId
       };
       loadProducts("products.csv",nameMapping,processors);
       
       //load the historic transactions - these are just randomly generated and do not respect stock quantity
       nameMapping = new String[]{"customerId","transactionDate","productId","quantity", "retailPrice", "id", "markUp", "orderStatus"};
       processors = new CellProcessor[] { 
       		new NotNull(),//customerId
       		new ParseDate("dd-MM-yyyy"),//transactionDate
       		new NotNull(),//productId
       		new ParseInt(),//quantity
       		new ParseDouble(),//retailsPrice
       		new NotNull(),//transactionId
       		new ParseDouble(),//markUp
       		new NotNull()//order status
       };
       loadTransactions("transactions.csv",nameMapping,processors);
       
       //load the mark ups
       nameMapping = new String[]{"id", "rate","levelName","qualifyingTransactionCountFloor","qualifyingTransactionCountCeiling"};
       processors = new CellProcessor[] {
       		new NotNull(),//id
       		new ParseDouble(),//rate
       		new NotNull(),//levelName
       		new ParseInt(),//qualifyingTransactionCountFloor
       		new ParseInt()//qualifyingTransactionCountCeiling
       };
       loadMarkUps("markUps.csv",nameMapping,processors);
       
       //clean out the alerts
       for (Alert alert : alertRepository.findAll()) {
       	alertRepository.delete(alert);
       }
       long endTime = new Date().getTime();
	long timeToLoad = endTime - startTime;
	activityLog.add("Total Loading Time: " + timeToLoad/1000 + " seconds");
       closeBeanReader();
	writeOutLogs();
}
 
开发者ID:Pivotal-Open-Source-Hub,项目名称:geode-demo-application,代码行数:68,代码来源:CacheLoader.java

示例9: getProcessors

import org.supercsv.cellprocessor.ParseDate; //导入依赖的package包/类
private static CellProcessor[] getProcessors() {
        
        final String emailRegex = "[a-z0-9\\._][email protected][a-z0-9\\.]+"; // just an example, not very robust!
        StrRegEx.registerMessage(emailRegex, "must be a valid email address");
        
        final CellProcessor[] processors = new CellProcessor[] { 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), //10
                new Optional(),//11
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), //20
                new Optional(), //21
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(new ParseDouble()),// 26 // Direct Labor Rate 
                new Optional(new ParseDouble()), //27 // hours
                new Optional(), 
                new Optional(), 
                new Optional(new ParseDouble()), //30 - Fringe Rate
                new Optional(), //31
                new Optional(new ParseDouble()), // OH Rate
                new Optional(), 
                new Optional(new ParseDouble()), // GAA Rate
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new ParseDate("MM/dd/yyyy"), // date
                new Optional(), //40
                new Optional(), //41
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(), 
                new Optional(),
                new Optional(), 
                new Optional(),//50 
                new Optional()
                /*new ParseDate("dd/MM/yyyy"), // birthDate
                new Optional(), // mailingAddress
                new Optional(new ParseBool()), // married
                new Optional(new ParseInt()), // numberOfKids
                new Optional(), // favouriteQuote*/
                
        };
        
        return processors;
}
 
开发者ID:SEMOSS,项目名称:semoss,代码行数:68,代码来源:JCRReader.java


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