Java Code Examples for java.time.format.DateTimeFormatter#RFC_1123_DATE_TIME
The following examples show how to use
java.time.format.DateTimeFormatter#RFC_1123_DATE_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: 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 2
Source File: PNGMetadata.java From Bytecoder with Apache License 2.0 | 6 votes |
void encodeImageCreationTimeToTextChunk() { // Check if Standard/Document/ImageCreationTime exists. if (creation_time_present) { // Check if a text chunk with creation time exists. if (tEXt_creation_time_present == false) { // No text chunk exists with image creation time. Add an entry. this.tEXt_keyword.add(tEXt_creationTimeKey); this.tEXt_text.add("Creation Time Place Holder"); // Update the iterator int index = tEXt_text.size() - 1; setCreationTimeChunk(tEXt_text.listIterator(index)); } // Encode image creation time with RFC1123 formatter OffsetDateTime offDateTime = OffsetDateTime.of(creation_time_year, creation_time_month, creation_time_day, creation_time_hour, creation_time_minute, creation_time_second, 0, creation_time_offset); DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; String encodedTime = offDateTime.format(formatter); setEncodedTime(encodedTime); } }
Example 3
Source File: RetryHeaderUtilsTest.java From FcmJava with MIT License | 6 votes |
@Test public void headerFoundWithDateTimeInFutureContentTest() { // We assume the HTTP Header to contain an RFC1123-compliant DateTime value: DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; String formattedStringInFuture = formatter.format(DateUtils.getUtcNow().plusYears(1)); // Expectations when(headerMock.getValue()) .thenReturn(formattedStringInFuture); when(httpResponseMock.getFirstHeader("Retry-After")) .thenReturn(headerMock); // Holds the Result: OutParameter<Duration> result = new OutParameter<>(); // Try to get the Result: boolean success = RetryHeaderUtils.tryDetermineRetryDelay(httpResponseMock, result); // Assertions: Assert.assertEquals(true, success); Assert.assertNotEquals(0, result.get().getSeconds()); Assert.assertTrue(result.get().getSeconds() > 120); }
Example 4
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 5
Source File: ContentDispositionTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void parseDates() { ContentDisposition disposition = ContentDisposition .parse("attachment; creation-date=\"Mon, 12 Feb 2007 10:15:30 -0500\"; " + "modification-date=\"Tue, 13 Feb 2007 10:15:30 -0500\"; " + "read-date=\"Wed, 14 Feb 2007 10:15:30 -0500\""); DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; assertEquals(ContentDisposition.builder("attachment") .creationDate(ZonedDateTime.parse("Mon, 12 Feb 2007 10:15:30 -0500", formatter)) .modificationDate(ZonedDateTime.parse("Tue, 13 Feb 2007 10:15:30 -0500", formatter)) .readDate(ZonedDateTime.parse("Wed, 14 Feb 2007 10:15:30 -0500", formatter)).build(), disposition); }
Example 6
Source File: ContentDispositionTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void parseInvalidDates() { ContentDisposition disposition = ContentDisposition .parse("attachment; creation-date=\"-1\"; modification-date=\"-1\"; " + "read-date=\"Wed, 14 Feb 2007 10:15:30 -0500\""); DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; assertEquals(ContentDisposition.builder("attachment") .readDate(ZonedDateTime.parse("Wed, 14 Feb 2007 10:15:30 -0500", formatter)).build(), disposition); }
Example 7
Source File: ContentDispositionTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void parseDates() { ContentDisposition disposition = ContentDisposition .parse("attachment; creation-date=\"Mon, 12 Feb 2007 10:15:30 -0500\"; " + "modification-date=\"Tue, 13 Feb 2007 10:15:30 -0500\"; " + "read-date=\"Wed, 14 Feb 2007 10:15:30 -0500\""); DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; assertEquals(ContentDisposition.builder("attachment") .creationDate(ZonedDateTime.parse("Mon, 12 Feb 2007 10:15:30 -0500", formatter)) .modificationDate(ZonedDateTime.parse("Tue, 13 Feb 2007 10:15:30 -0500", formatter)) .readDate(ZonedDateTime.parse("Wed, 14 Feb 2007 10:15:30 -0500", formatter)).build(), disposition); }
Example 8
Source File: ContentDispositionTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void parseInvalidDates() { ContentDisposition disposition = ContentDisposition .parse("attachment; creation-date=\"-1\"; modification-date=\"-1\"; " + "read-date=\"Wed, 14 Feb 2007 10:15:30 -0500\""); DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; assertEquals(ContentDisposition.builder("attachment") .readDate(ZonedDateTime.parse("Wed, 14 Feb 2007 10:15:30 -0500", formatter)).build(), disposition); }
Example 9
Source File: RetryHeaderUtils.java From FcmJava with MIT License | 5 votes |
private static boolean tryToConvertToDate(String dateAsString, OutParameter<ZonedDateTime> result) { try { // We assume the HTTP Header to contain an RFC1123-compliant DateTime value: DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; // Try to parse and set it as the result: result.set(ZonedDateTime.parse(dateAsString, formatter)); return true; } catch (Exception e) { return false; } }
Example 10
Source File: DateTimeFormatterTest.java From j2objc with Apache License 2.0 | 5 votes |
@Test public void test_getDecimalStyle() { Locale arLocale = Locale.forLanguageTag("ar"); DateTimeFormatter[] formatters = new DateTimeFormatter[] { DateTimeFormatter.ISO_DATE, DateTimeFormatter.RFC_1123_DATE_TIME, new DateTimeFormatterBuilder().toFormatter(), new DateTimeFormatterBuilder().toFormatter(Locale.ROOT), new DateTimeFormatterBuilder().toFormatter(Locale.ENGLISH), new DateTimeFormatterBuilder().toFormatter(arLocale), }; DecimalStyle arDecimalStyle = DecimalStyle.of(arLocale); // Verify that the Locale ar returns a DecimalStyle other than STANDARD. assertNotEquals(DecimalStyle.STANDARD, arDecimalStyle); for (DateTimeFormatter formatter : formatters) { // All DateTimeFormatters should use the standard style, unless explicitly changed. assertEquals(formatter.toString(), DecimalStyle.STANDARD, formatter.getDecimalStyle()); DateTimeFormatter arStyleFormatter = formatter.withDecimalStyle(arDecimalStyle); assertEquals(arStyleFormatter.toString(), arDecimalStyle, arStyleFormatter.getDecimalStyle()); // Verify that calling withDecimalStyle() doesn't modify the original formatter. assertEquals(formatter.toString(), DecimalStyle.STANDARD, formatter.getDecimalStyle()); } }
Example 11
Source File: TimeZoneTest.java From SA47 with The Unlicense | 4 votes |
public void display(ZonedDateTime time) { DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; System.out.println(time.format(formatter)); System.out.println(); }