datetimeformatter

What is the correct DateTimeFormatter pattern for datetimeoffset column

╄→尐↘猪︶ㄣ 提交于 2021-02-11 15:01:35
问题 What is the correct DateTimeFormatter pattern for querying a SQL Server table by a datetimeoffset column. When I execute the below query, I get results. What is the correct pattern I should use to run the same query from the java app? SELECT * FROM TABLE WHERE CreateTimestamp >= '2020-07-06 06:00:00.0000000 +00:00' Below is the java code snippet I use to convert the date: public String convertToDatabaseColumn(OffsetDateTime offsetDateTime) { DateTimeFormatter formatter = DateTimeFormatter

Kotlin DateTimeParseException

此生再无相见时 提交于 2021-02-11 12:32:24
问题 Getting date from https://api.spacexdata.com/v3/launches This date have format: 2006-03-25T10:30:00+12:00. I want convert it to "dd, mm, yyyy", but always getting error: "java.time.format.DateTimeParseException: Text '2006-03-25T10:30:00+12:00' could not be parsed, unparsed text found at index 10" my code: val formatter = DateTimeFormatter.ofPattern("dd, mm, yyyy", Locale.US) val myDate = LocalDate.parse(launchDate, formatter) var launchDateConverted: String= myDate.toString() i getting data

Databse DateTime milli & nano seconds are truncated by default if its 0s while using it in java-11 using ZonedDateTime

混江龙づ霸主 提交于 2021-02-11 07:58:11
问题 I am fetching datetime from oracle db and parsing in java-11 using ZonedDateTime as below: oracle --> 1/19/2020 06:09:46.038631 PM java ZonedDateTime 0/p --> 2020-01-19T18:09:46.038631Z[UTC] oracle --> 1/19/2011 4:00:00.000000 AM java ZonedDateTime o/p --> 2011-01-19T04:00Z[UTC] (So, here the 0s are truncated by default. However, my requirement is to have consistent fixed length o/p like #1.) expected java ZonedDateTime o/p --> 2011-01-19T04:00:00.000000Z[UTC] However, I didnt find any date

DateTimeFormatter issue

折月煮酒 提交于 2021-02-10 15:15:19
问题 See the following test code (java 11): public static final String DATE_FORMAT_TIMESTAMP = "YYYY-MM-dd'T'HH:mm:ss'Z'"; ... var timestamp = OffsetDateTime.now(); System.out.println(timestamp); var formatter = DateTimeFormatter.ofPattern(DATE_FORMAT_TIMESTAMP); var zt = timestamp.format(formatter); System.out.println(zt); ... The output: enter code here 2020-12-27T23:34:34.886272600+02:00 2021-12-27T23:34:34Z Note formatted time year is 2021 . And it happens only from 27/12, probably till 31/12.

Timestamp can't be parsed Issue java.time.format.DateTimeParseException: Text '9/25/2020, 12:46:00 PM' could not be parsed at index 0 [duplicate]

自古美人都是妖i 提交于 2021-02-02 09:46:05
问题 This question already has answers here : Error: Text '1/31/2020' could not be parsed at index 0 while trying to parse string date (2 answers) Problem with parse a LocalDateTime using java 8 (2 answers) How to parse a 1 or 2 digit hour string with Java? (5 answers) Closed 4 months ago . I am attempting to capture the time before and after I check a timestamp value on a webpage and then confirm my timestamp falls in between those times. However, I'm struggling to convert my String timestamp

ZonedDateTime from date string in yyyy-mm-dd

牧云@^-^@ 提交于 2021-01-07 02:42:29
问题 Trying to parse a ZonedDateTime from a date string e.g '2020-08-24'. Upon using TemporalAccesor, and DateTimeFormatter.ISO_OFFSET_DATE to parse, I am getting a java.time.format.DateTimeParseException. Am I using the wrong formatter? Even tried adding 'Z' at the end of date string for it to be understood as UTC private ZonedDateTime getZonedDateTime(String dateString) { TemporalAccessor parsed = null; dateString = dateString + 'Z'; try { parsed = DateTimeFormatter.ISO_OFFSET_DATE.parse