Java Code Examples for java.time.format.DateTimeFormatter#ISO_LOCAL_TIME
The following examples show how to use
java.time.format.DateTimeFormatter#ISO_LOCAL_TIME .
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 |
@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 java-technology-stack with MIT License | 6 votes |
@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: PutSQL.java From localization_nifi with Apache License 2.0 | 6 votes |
private 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 4
Source File: Jsr310DateTimeFormatAnnotationFormatterFactory.java From lams with GNU General Public License v2.0 | 6 votes |
@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 5
Source File: JdbcCommon.java From nifi with Apache License 2.0 | 6 votes |
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 6
Source File: TypeConverter.java From sailfish-core with Apache License 2.0 | 4 votes |
public static LocalTime getLocalTime(String value) { DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_TIME; return LocalTime.parse(value, formatter); }
Example 7
Source File: TypeConverter.java From sailfish-core with Apache License 2.0 | 4 votes |
public static String getString(LocalTime value) { DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_TIME; return value.format(formatter); }
Example 8
Source File: LocalTimeSerializer.java From jackson-modules-java8 with Apache License 2.0 | 4 votes |
protected DateTimeFormatter _defaultFormatter() { return DateTimeFormatter.ISO_LOCAL_TIME; }
Example 9
Source File: LocalTimeDeserializer.java From bootique with Apache License 2.0 | 4 votes |
private LocalTimeDeserializer() { this(DateTimeFormatter.ISO_LOCAL_TIME); }
Example 10
Source File: TimeTypeAdapter.java From jsonstream with Apache License 2.0 | 4 votes |
public TimeTypeAdapter() { this.formatter = DateTimeFormatter.ISO_LOCAL_TIME; }
Example 11
Source File: LocalTimeXmlAdapter.java From threeten-jaxb with Apache License 2.0 | 4 votes |
public LocalTimeXmlAdapter() { super(DateTimeFormatter.ISO_LOCAL_TIME, LocalTime::from); }
Example 12
Source File: TimeTypeAdapter.java From jsonstream with Apache License 2.0 | 4 votes |
public TimeTypeAdapter() { this.formatter = DateTimeFormatter.ISO_LOCAL_TIME; }
Example 13
Source File: ParseLocalTimeTest.java From super-csv with Apache License 2.0 | 4 votes |
@Test public void testConstructor4WithNullNext() { exception.expect(NullPointerException.class); new ParseLocalTime(DateTimeFormatter.ISO_LOCAL_TIME, null); }
Example 14
Source File: FmtLocalTimeTest.java From super-csv with Apache License 2.0 | 4 votes |
@Test public void testConstructor4WithNullNext() { exception.expect(NullPointerException.class); new FmtLocalTime(DateTimeFormatter.ISO_LOCAL_TIME, null); }
Example 15
Source File: JavaTimeTypesParamConverterProvider.java From cxf with Apache License 2.0 | 4 votes |
protected DateTimeFormatter getFormatter() { return DateTimeFormatter.ISO_LOCAL_TIME; }
Example 16
Source File: TestPutSQL.java From nifi with Apache License 2.0 | 4 votes |
@Test public void testUsingDateTimeValuesWithFormatAttribute() throws InitializationException, ProcessException, SQLException, IOException, ParseException { final TestRunner runner = TestRunners.newTestRunner(PutSQL.class); try (final Connection conn = service.getConnection()) { try (final Statement stmt = conn.createStatement()) { stmt.executeUpdate("CREATE TABLE TIMESTAMPTEST3 (id integer primary key, ts1 TIME, ts2 DATE)"); } } runner.addControllerService("dbcp", service); runner.enableControllerService(service); runner.setProperty(PutSQL.CONNECTION_POOL, "dbcp"); final String dateStr = "2002-03-04"; final String timeStr = "02:03:04"; final String timeFormatString = "HH:mm:ss"; final String dateFormatString ="yyyy-MM-dd"; final DateTimeFormatter timeFormatter= DateTimeFormatter.ISO_LOCAL_TIME; LocalTime parsedTime = LocalTime.parse(timeStr, timeFormatter); Time expectedTime = Time.valueOf(parsedTime); final DateTimeFormatter dateFormatter = DateTimeFormatter.ISO_LOCAL_DATE; LocalDate parsedDate = LocalDate.parse(dateStr, dateFormatter); Date expectedDate = new Date(Date.from(parsedDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()).getTime()); final long expectedTimeInLong = expectedTime.getTime(); final long expectedDateInLong = expectedDate.getTime(); // test with ISO LOCAL format attribute Map<String, String> attributes = new HashMap<>(); attributes.put("sql.args.1.type", String.valueOf(Types.TIME)); attributes.put("sql.args.1.value", timeStr); attributes.put("sql.args.1.format", "ISO_LOCAL_TIME"); attributes.put("sql.args.2.type", String.valueOf(Types.DATE)); attributes.put("sql.args.2.value", dateStr); attributes.put("sql.args.2.format", "ISO_LOCAL_DATE"); runner.enqueue("INSERT INTO TIMESTAMPTEST3 (ID, ts1, ts2) VALUES (1, ?, ?)".getBytes(), attributes); // Since Derby database which is used for unit test does not have timezone in DATE and TIME type, // and PutSQL converts date string into long representation using local timezone, // we need to use local timezone. SimpleDateFormat timeFormat = new SimpleDateFormat(timeFormatString); java.util.Date parsedLocalTime = timeFormat.parse(timeStr); SimpleDateFormat dateFormat = new SimpleDateFormat(dateFormatString); java.util.Date parsedLocalDate = dateFormat.parse(dateStr); // test Long pattern without format attribute attributes = new HashMap<>(); attributes.put("sql.args.1.type", String.valueOf(Types.TIME)); attributes.put("sql.args.1.value", Long.toString(parsedLocalTime.getTime())); attributes.put("sql.args.2.type", String.valueOf(Types.DATE)); attributes.put("sql.args.2.value", Long.toString(parsedLocalDate.getTime())); runner.enqueue("INSERT INTO TIMESTAMPTEST3 (ID, ts1, ts2) VALUES (2, ?, ?)".getBytes(), attributes); // test with format attribute attributes = new HashMap<>(); attributes.put("sql.args.1.type", String.valueOf(Types.TIME)); attributes.put("sql.args.1.value", "020304000"); attributes.put("sql.args.1.format", "HHmmssSSS"); attributes.put("sql.args.2.type", String.valueOf(Types.DATE)); attributes.put("sql.args.2.value", "20020304"); attributes.put("sql.args.2.format", "yyyyMMdd"); runner.enqueue("INSERT INTO TIMESTAMPTEST3 (ID, ts1, ts2) VALUES (3, ?, ?)".getBytes(), attributes); runner.run(); runner.assertAllFlowFilesTransferred(PutSQL.REL_SUCCESS, 3); try (final Connection conn = service.getConnection()) { try (final Statement stmt = conn.createStatement()) { final ResultSet rs = stmt.executeQuery("SELECT * FROM TIMESTAMPTEST3 ORDER BY ID"); assertTrue(rs.next()); assertEquals(1, rs.getInt(1)); assertEquals(expectedTimeInLong, rs.getTime(2).getTime()); assertEquals(expectedDateInLong, rs.getDate(3).getTime()); assertTrue(rs.next()); assertEquals(2, rs.getInt(1)); assertEquals(parsedLocalTime.getTime(), rs.getTime(2).getTime()); assertEquals(parsedLocalDate.getTime(), rs.getDate(3).getTime()); assertTrue(rs.next()); assertEquals(3, rs.getInt(1)); assertEquals(expectedTimeInLong, rs.getTime(2).getTime()); assertEquals(expectedDateInLong, rs.getDate(3).getTime()); assertFalse(rs.next()); } } }