Java 8 DateTimeFormatterBuilder - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DateTimeFormatterBuilder class.

This code example shows how to use the following methods:appendLiteral, appendValue, toFormatter
public class YearMothKeyDeserializer extends Jsr310KeyDeserializer { 
 
    public static final YearMothKeyDeserializer INSTANCE = new YearMothKeyDeserializer();
 
    // parser copied from YearMonth 
    private static final DateTimeFormatter FORMATTER = new DateTimeFormatterBuilder()
            .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
            .appendLiteral('-')
            .appendValue(MONTH_OF_YEAR, 2)
            .toFormatter();
 
    private YearMothKeyDeserializer() { 
        // singleton 
    } 
 
    @Override 
    protected YearMonth deserialize(String key, DeserializationContext ctxt) throws IOException {
        try { 
            return YearMonth.parse(key, FORMATTER);
        } catch (DateTimeException e) {
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:appendLiteral, appendValue, toFormatter
public class MonthDayKeyDeserializer extends Jsr310KeyDeserializer { 
 
    public static final MonthDayKeyDeserializer INSTANCE = new MonthDayKeyDeserializer();
 
    // formatter copied from MonthDay 
    private static final DateTimeFormatter PARSER = new DateTimeFormatterBuilder()
            .appendLiteral("--")
            .appendValue(MONTH_OF_YEAR, 2)
            .appendLiteral('-')
            .appendValue(DAY_OF_MONTH, 2)
            .toFormatter();
 
    private MonthDayKeyDeserializer() { 
        // singleton 
    } 
 
    @Override 
    protected MonthDay deserialize(String key, DeserializationContext ctxt) throws IOException {
        try { 
            return MonthDay.parse(key, PARSER);
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:appendValue, toFormatter
    public static final YearKeyDeserializer INSTANCE = new YearKeyDeserializer();
 
    /* 
     * formatter copied from Year. There is no way of getting a reference to the formatter it uses. 
     */ 
    private static final DateTimeFormatter FORMATTER = new DateTimeFormatterBuilder()
            .appendValue(YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
            .toFormatter();
 
    private YearKeyDeserializer() { 
        // singleton 
    } 
 
    @Override 
    protected Year deserialize(String key, DeserializationContext ctxt) throws IOException {
        try { 
            return Year.parse(key, FORMATTER);
        } catch (DateTimeException e) {
            return _rethrowDateTimeException(ctxt, Year.class, e, key);
        } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
public class DateColumnMonthDayMapper extends AbstractDateThreeTenColumnMapper<MonthDay> implements DatabaseZoneConfigured<ZoneOffset> {
 
    private static final long serialVersionUID = 6734385103313158326L;
 
    public static final DateTimeFormatter LOCAL_DATE_FORMATTER = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd").toFormatter();
 
//	private static final int MILLIS_IN_SECOND = 1000; 
     
	public DateColumnMonthDayMapper() { 
	} 
 
	public DateColumnMonthDayMapper(ZoneOffset databaseZone) {
		super(databaseZone);
	} 
     
    @Override 
    public MonthDay fromNonNullString(String s) {
        return MonthDay.parse(s);
    } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
public class TimeColumnOffsetTimeMapper extends AbstractTimeThreeTenColumnMapper<OffsetTime> implements DatabaseZoneConfigured<ZoneOffset>, JavaZoneConfigured<ZoneOffset> {
 
    private static final long serialVersionUID = 6734385103313158326L;
 
    public static final DateTimeFormatter LOCAL_TIME_FORMATTER = new DateTimeFormatterBuilder().appendPattern("HH:mm:ss").toFormatter();
 
    private ZoneOffset databaseZone = ZoneOffset.UTC;
 
    private ZoneOffset javaZone = null;
 
	public TimeColumnOffsetTimeMapper() { 
	} 
 
	public TimeColumnOffsetTimeMapper(ZoneOffset databaseZone, ZoneOffset javaZone) {
		this.databaseZone = databaseZone;
		this.javaZone = javaZone;
	} 
     
    @Override 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
public class TimestampColumnLocalTimeMapper extends AbstractTimestampThreeTenColumnMapper<LocalTime> implements DatabaseZoneConfigured<ZoneOffset> {
 
    private static final long serialVersionUID = 1921591625617366103L;
 
    public static final DateTimeFormatter LOCAL_DATETIME_PRINTER = new DateTimeFormatterBuilder().appendPattern("0001-01-01 HH:mm:ss").appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true).toFormatter();
    public static final DateTimeFormatter LOCAL_DATETIME_PARSER = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss").appendFraction(ChronoField.NANO_OF_SECOND, 0, 9, true).toFormatter();
 
	private static final int MILLIS_IN_SECOND = 1000;
     
	public TimestampColumnLocalTimeMapper() { 
		super(null); 
	} 
 
	public TimestampColumnLocalTimeMapper(ZoneOffset databaseZone) {
		super(databaseZone);
	} 
     
    @Override 
    public LocalTime fromNonNullString(String s) {
        return LocalTime.parse(s);
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
public class DateColumnLocalDateMapper extends AbstractDateThreeTenColumnMapper<LocalDate> implements DatabaseZoneConfigured<ZoneOffset> {
 
    private static final long serialVersionUID = 6734385103313158326L;
 
    public static final DateTimeFormatter LOCAL_DATE_FORMATTER = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd").toFormatter();
 
//	private static final int MILLIS_IN_SECOND = 1000; 
     
	public DateColumnLocalDateMapper() { 
	} 
 
	public DateColumnLocalDateMapper(ZoneOffset databaseZone) {
		super(databaseZone);
	} 
     
    @Override 
    public LocalDate fromNonNullString(String s) {
        return LocalDate.parse(s);
    } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
    private static final long serialVersionUID = 6734385103313158326L;
 
    private ZoneOffset databaseZone = null;
     
    public static final DateTimeFormatter LOCAL_TIME_FORMATTER = new DateTimeFormatterBuilder().appendPattern("HH:mm:ss").toFormatter();
 
	public TimeColumnLocalTimeMapper() { 
	} 
 
	public TimeColumnLocalTimeMapper(ZoneOffset databaseZone) {
		this.databaseZone = databaseZone;
	} 
     
    @Override 
    public LocalTime fromNonNullString(String s) {
        return LocalTime.parse(s);
    } 
 
    @Override 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
public class TimestampColumnMonthDayMapper extends AbstractTimestampThreeTenColumnMapper<MonthDay> implements DatabaseZoneConfigured<ZoneOffset> {
 
    private static final long serialVersionUID = -7670411089210984705L;
     
    public static final DateTimeFormatter LOCAL_DATETIME_FORMATTER = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss").appendOptional(new DateTimeFormatterBuilder().appendLiteral('.').appendFraction(ChronoField.NANO_OF_SECOND, 1, 9, false).toFormatter()).toFormatter();
 
	public TimestampColumnMonthDayMapper() { 
		super(); 
	} 
 
	public TimestampColumnMonthDayMapper(ZoneOffset databaseZone) {
		super(databaseZone);
	} 
     
    @Override 
    public MonthDay fromNonNullString(String s) {
        return MonthDay.parse(s);
    } 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
public class TimestampColumnLocalDateTimeMapper extends AbstractTimestampThreeTenColumnMapper<LocalDateTime> implements DatabaseZoneConfigured<ZoneOffset> {
 
    private static final long serialVersionUID = -7670411089210984705L;
     
    public static final DateTimeFormatter LOCAL_DATETIME_FORMATTER = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss").appendOptional(new DateTimeFormatterBuilder().appendLiteral('.').appendFraction(ChronoField.NANO_OF_SECOND, 1, 9, false).toFormatter()).toFormatter();
 
	public TimestampColumnLocalDateTimeMapper() { 
		super(); 
	} 
 
	public TimestampColumnLocalDateTimeMapper(ZoneOffset databaseZone) {
		super(databaseZone);
	} 
     
    @Override 
    public LocalDateTime fromNonNullString(String s) {
        return LocalDateTime.parse(s);
    } 
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 DateTimeFormatterBuilder Methods: