Java Code Examples for java.time.format.DateTimeFormatter#ISO_LOCAL_DATE

The following examples show how to use java.time.format.DateTimeFormatter#ISO_LOCAL_DATE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Jsr310DateTimeFormatAnnotationFormatterFactory.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public Printer<?> getPrinter(DateTimeFormat annotation, Class<?> fieldType) {
	DateTimeFormatter formatter = getFormatter(annotation, fieldType);

	// Efficient ISO_LOCAL_* variants for printing since they are twice as fast...
	if (formatter == DateTimeFormatter.ISO_DATE) {
		if (isLocal(fieldType)) {
			formatter = DateTimeFormatter.ISO_LOCAL_DATE;
		}
	}
	else if (formatter == DateTimeFormatter.ISO_TIME) {
		if (isLocal(fieldType)) {
			formatter = DateTimeFormatter.ISO_LOCAL_TIME;
		}
	}
	else if (formatter == DateTimeFormatter.ISO_DATE_TIME) {
		if (isLocal(fieldType)) {
			formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
		}
	}

	return new TemporalAccessorPrinter(formatter);
}
 
Example 2
Source File: Jsr310DateTimeFormatAnnotationFormatterFactory.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Printer<?> getPrinter(DateTimeFormat annotation, Class<?> fieldType) {
	DateTimeFormatter formatter = getFormatter(annotation, fieldType);

	// Efficient ISO_LOCAL_* variants for printing since they are twice as fast...
	if (formatter == DateTimeFormatter.ISO_DATE) {
		if (isLocal(fieldType)) {
			formatter = DateTimeFormatter.ISO_LOCAL_DATE;
		}
	}
	else if (formatter == DateTimeFormatter.ISO_TIME) {
		if (isLocal(fieldType)) {
			formatter = DateTimeFormatter.ISO_LOCAL_TIME;
		}
	}
	else if (formatter == DateTimeFormatter.ISO_DATE_TIME) {
		if (isLocal(fieldType)) {
			formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
		}
	}

	return new TemporalAccessorPrinter(formatter);
}
 
Example 3
Source File: VulnerabilityTrendGenerator2.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the date range.
 *
 * @param from the from
 * @param to the to
 * @param excludeBefore the exclude before
 * @param inputFormatter the input formatter
 * @return the date range
 */
private List<String> getDateRange(Object from, Object to, LocalDate excludeBefore, DateTimeFormatter inputFormatter){
    LocalDate fromDt;
    LocalDate toDt;
    List<String> dateRage = new ArrayList<>();
    if(from!=null){
        fromDt = LocalDate.parse(from.toString(),inputFormatter);
        if(fromDt.isBefore(excludeBefore)) {
        	fromDt = excludeBefore;
        }
        if(to==null){
            toDt = LocalDate.now();
        }else{
            toDt = LocalDate.parse(to.toString(),inputFormatter);
        }
        DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
        int daysBetween = (int) ChronoUnit.DAYS.between(fromDt, toDt);
        
        for(int i=0;i<daysBetween;i++ ) {
        	dateRage.add(formatter.format(fromDt.plusDays(i)));
         };
    }
    return dateRage;
}
 
Example 4
Source File: VulnerabilityTrendGenerator.java    From pacbot with Apache License 2.0 6 votes vote down vote up
private List<DateResInfo> getDateRangeWithResourceId(Object from, Object to, LocalDate excludeBefore, DateTimeFormatter inputFormatter,String resourceId){
    LocalDate fromDt;
    LocalDate toDt;
    List<DateResInfo> dateRage = new ArrayList<>();
    if(from!=null){
        fromDt = LocalDateTime.parse(from.toString(),inputFormatter).toLocalDate();
        if(to==null){
            toDt = LocalDate.now();
        }else{
            toDt = LocalDateTime.parse(to.toString(),inputFormatter).toLocalDate();
        }
        DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
        while(fromDt.isBefore(toDt)){
            if(!fromDt.isBefore(excludeBefore)){
                dateRage.add(new DateResInfo(formatter.format(fromDt),resourceId));
            }
            fromDt = fromDt.plusDays(1);
         }
    }
    return dateRage;
}
 
Example 5
Source File: VulnerabilityTrendGenerator.java    From pacbot with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the date range.
 *
 * @param from the from
 * @param to the to
 * @param excludeBefore the exclude before
 * @param inputFormatter the input formatter
 * @return the date range
 */
private List<String> getDateRange(Object from, Object to, LocalDate excludeBefore, DateTimeFormatter inputFormatter){
    LocalDate fromDt;
    LocalDate toDt;
    List<String> dateRage = new ArrayList<>();
    if(from!=null){
        fromDt = LocalDateTime.parse(from.toString(),inputFormatter).toLocalDate();
        if(to==null){
            toDt = LocalDate.now();
        }else{
            toDt = LocalDateTime.parse(to.toString(),inputFormatter).toLocalDate();
        }
        DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
        while(fromDt.isBefore(toDt)){
            if(!fromDt.isBefore(excludeBefore)){
                dateRage.add(formatter.format(fromDt));
            }
            fromDt = fromDt.plusDays(1);
         }
    }
    return dateRage;
}
 
Example 6
Source File: Jsr310DateTimeFormatAnnotationFormatterFactory.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public Printer<?> getPrinter(DateTimeFormat annotation, Class<?> fieldType) {
	DateTimeFormatter formatter = getFormatter(annotation, fieldType);

	// Efficient ISO_LOCAL_* variants for printing since they are twice as fast...
	if (formatter == DateTimeFormatter.ISO_DATE) {
		if (isLocal(fieldType)) {
			formatter = DateTimeFormatter.ISO_LOCAL_DATE;
		}
	}
	else if (formatter == DateTimeFormatter.ISO_TIME) {
		if (isLocal(fieldType)) {
			formatter = DateTimeFormatter.ISO_LOCAL_TIME;
		}
	}
	else if (formatter == DateTimeFormatter.ISO_DATE_TIME) {
		if (isLocal(fieldType)) {
			formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
		}
	}

	return new TemporalAccessorPrinter(formatter);
}
 
Example 7
Source File: JdbcCommon.java    From nifi with Apache License 2.0 6 votes vote down vote up
public static DateTimeFormatter getDateTimeFormatter(String pattern) {
    switch(pattern) {
        case "BASIC_ISO_DATE": return DateTimeFormatter.BASIC_ISO_DATE;
        case "ISO_LOCAL_DATE": return DateTimeFormatter.ISO_LOCAL_DATE;
        case "ISO_OFFSET_DATE": return DateTimeFormatter.ISO_OFFSET_DATE;
        case "ISO_DATE": return DateTimeFormatter.ISO_DATE;
        case "ISO_LOCAL_TIME": return DateTimeFormatter.ISO_LOCAL_TIME;
        case "ISO_OFFSET_TIME": return DateTimeFormatter.ISO_OFFSET_TIME;
        case "ISO_TIME": return DateTimeFormatter.ISO_TIME;
        case "ISO_LOCAL_DATE_TIME": return DateTimeFormatter.ISO_LOCAL_DATE_TIME;
        case "ISO_OFFSET_DATE_TIME": return DateTimeFormatter.ISO_OFFSET_DATE_TIME;
        case "ISO_ZONED_DATE_TIME": return DateTimeFormatter.ISO_ZONED_DATE_TIME;
        case "ISO_DATE_TIME": return DateTimeFormatter.ISO_DATE_TIME;
        case "ISO_ORDINAL_DATE": return DateTimeFormatter.ISO_ORDINAL_DATE;
        case "ISO_WEEK_DATE": return DateTimeFormatter.ISO_WEEK_DATE;
        case "ISO_INSTANT": return DateTimeFormatter.ISO_INSTANT;
        case "RFC_1123_DATE_TIME": return DateTimeFormatter.RFC_1123_DATE_TIME;
        default: return DateTimeFormatter.ofPattern(pattern);
    }
}
 
Example 8
Source File: Events_DataFusion_Main.java    From winter with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws XPathExpressionException,
			ParserConfigurationException, SAXException, IOException,
			TransformerException {

		char separator = '+';
		DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
		boolean filterFrom = false;
		boolean filterTo = false;
		boolean applyKeywordSearch = false;
		LocalDate fromDate = LocalDate.MIN;
		LocalDate toDate = LocalDate.MAX;
		String keyword = "";

		// Load the Data into FusableDataSet
		FusibleDataSet<Event, Attribute> fusibleDataSetD = new FusibleHashedDataSet<>();
//		fusibleDataSetD.loadFromTSV(new File("WDI/usecase/event/input/dbpedia-1_s.tsv"),
//				new EventFactory(dateTimeFormatter, filterFrom, fromDate, filterTo, toDate, applyKeywordSearch, keyword), "events/event", separator, dateTimeFormatter, false, fromDate, false, toDate, true, keyword);


		FusibleDataSet<Event, Attribute> fusibleDataSetY = new FusibleHashedDataSet<>();
//		fusibleDataSetY.loadFromTSV(new File("WDI/usecase/event/input/yago-1_s.tsv"),
//				new EventFactory(dateTimeFormatter, filterFrom, fromDate, filterTo, toDate, applyKeywordSearch, keyword), "events/event", separator, dateTimeFormatter, false, fromDate, false, toDate, true, keyword);


		runDataFusion(fusibleDataSetD,
				fusibleDataSetY,
				//null,
				separator, dateTimeFormatter, filterFrom, fromDate, filterTo, toDate, applyKeywordSearch, keyword);

	}
 
Example 9
Source File: JSON.java    From influxdb-client-java with MIT License 4 votes vote down vote up
public LocalDateTypeAdapter() {
    this(DateTimeFormatter.ISO_LOCAL_DATE);
}
 
Example 10
Source File: ParseLocalDateTest.java    From super-csv with Apache License 2.0 4 votes vote down vote up
@Test(expected = NullPointerException.class)
public void testConstructor4WithNullNext() {
	new ParseLocalDate(DateTimeFormatter.ISO_LOCAL_DATE, null);
}
 
Example 11
Source File: TypeConverter.java    From sailfish-core with Apache License 2.0 4 votes vote down vote up
public static LocalDate getLocalDate(String value) {
    DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE; //'2011-12-03'
    return LocalDate.parse(value, formatter);
}
 
Example 12
Source File: TypeConverter.java    From sailfish-core with Apache License 2.0 4 votes vote down vote up
public static String getString(LocalDate value) {
    DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE;
    return value.format(formatter);
}
 
Example 13
Source File: DateTypeAdapter.java    From jsonstream with Apache License 2.0 4 votes vote down vote up
public DateTypeAdapter() {
    this.formatter = DateTimeFormatter.ISO_LOCAL_DATE;
}
 
Example 14
Source File: FmtLocalDateTest.java    From super-csv with Apache License 2.0 4 votes vote down vote up
@Test
public void testConstructor4WithNullNext() {
	exception.expect(NullPointerException.class);
	new FmtLocalDate(DateTimeFormatter.ISO_LOCAL_DATE, null);
}
 
Example 15
Source File: GraphQLLocalDate.java    From graphql-java-datetime with Apache License 2.0 4 votes vote down vote up
public GraphQLLocalDate(final String name, boolean zoneConversionEnabled) {
    this(name, zoneConversionEnabled, DateTimeFormatter.ISO_LOCAL_DATE);
}
 
Example 16
Source File: MCRISO8601FormatChooser.java    From mycore with GNU General Public License v3.0 4 votes vote down vote up
public static DateTimeFormatter date() {
    return DateTimeFormatter.ISO_LOCAL_DATE;
}
 
Example 17
Source File: JSON.java    From eve-esi with Apache License 2.0 4 votes vote down vote up
public LocalDateTypeAdapter() {
    this(DateTimeFormatter.ISO_LOCAL_DATE);
}
 
Example 18
Source File: DateTypeAdapter.java    From jsonstream with Apache License 2.0 4 votes vote down vote up
public DateTypeAdapter() {
    this.formatter = DateTimeFormatter.ISO_LOCAL_DATE;
}
 
Example 19
Source File: DateFormatValidator.java    From json-schema with Apache License 2.0 4 votes vote down vote up
public DateFormatValidator() {
    super(DateTimeFormatter.ISO_LOCAL_DATE, Collections.singletonList("yyyy-MM-dd").toString());
}
 
Example 20
Source File: DateValidator.java    From govpay with GNU General Public License v3.0 4 votes vote down vote up
protected DateValidator(String fieldName, Date fieldValue) { 
	this.fieldName = fieldName;
	this.fieldValue = fieldValue == null ? null : fieldValue.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
	this.formatter = DateTimeFormatter.ISO_LOCAL_DATE;
}