Questions tagged [threetenbp]

ThreeTen-Backport is the backport of JSR-310 to Java SE 7. Questions about "java.time" in Java SE 8 should use the [java-time] tag. Only questions specifically about the backport should use this tag.

ThreeTen-Backport is the backport of JSR-310 to Java SE 7. Questions about java.time in Java SE 8 should use the tag. Only questions specifically about the backport should use this tag.

95 questions
2
votes
2 answers

Java 8 time: Iterate over a day's LocalTime in period steps

Starting at midnight, I want to iterate over LocalTimes in steps of a certain period length to the end of the day. Eg. if the period is 8hr10Minutes I would like times: 0:00, 8:10, 16:20 (not 24:30 as this is the next day) I have the following…
Philipp
  • 4,659
  • 9
  • 48
  • 69
1
vote
0 answers

org.threeten.bp zonedDateTime.parse does not work

Hi I am trying to use org.threeten.bp library and format a date string to zonnedDateTime but it does not work. val dateFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") val aOne = ZonedDateTime.parse("2022-08-11",…
BRDroid
  • 3,920
  • 8
  • 65
  • 143
1
vote
1 answer

Date: getDisplayName method adds point character to dayOfWeek only on CI

Calling localDate.getDayOfWeek().getDisplayName in my UnitTest running on CircleCI returns a different value compared to running the UnitTest locally. Here is the simplified sample code: LocalDate localDate = LocalDate.of(2019, 12, 20); String…
goemic
  • 1,092
  • 12
  • 24
1
vote
1 answer

Parse multiple patterns using org.threeten.bp.format.DateTimeFormatter

Simple version: I need to be able to parse two types of Timestamp strings using only one org.threeten.bp.format.DateTimeFormatter object. Pattern 1 ("YYYY-MM-DD HH:mm:ss.SSSSSS" -- this code works): DateTimeFormatter dtf =…
ryvantage
  • 13,064
  • 15
  • 63
  • 112
1
vote
1 answer

java.lang.ClassNotFoundException: org.threeten.bp.temporal.TemporalAccessor

I am using threetenbp version 1.4.4 in my maven project. On deploying my JAR in a tomcat container, I get the exception below: java.lang.NoClassDefFoundError: "org/threeten/bp/temporal/TemporalAccessor" Caused by: …
Tapiwa
  • 49
  • 6
1
vote
0 answers

Jackson databind InvalidFormatException : Failed to deserialize org.threeten.bp.ZonedDateTime

How to fixe the InvalidFormatException for 2019-12-01T06:16:50.289+0000 Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `org.threeten.bp.ZonedDateTime` from String…
Chathura Wijesinghe
  • 3,310
  • 3
  • 25
  • 41
1
vote
1 answer

Why is my UTC instant not converting to BST?

I have the following code: SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.UK); Instant inst = DateTimeUtils.toInstant(sdf.parse("2019-08-13T18:00:00Z")); DateTimeFormatter formatter =…
Chris Knight
  • 24,333
  • 24
  • 88
  • 134
1
vote
1 answer

Android ThreeTen ABP library not working in unit tests (ZoneRulesException)

When I attempt to use Jake Wharton's Android ThreeTen ABP library, in unit tests, I get an exception: org.threeten.bp.zone.ZoneRulesException: No time-zone data files registered This question explains that init may have not been called, but how do…
Justin Meiners
  • 10,754
  • 6
  • 50
  • 92
1
vote
3 answers

How to get zone name that respects daylight saving (e.g. EDT)

I have ZonedDateTime instance, trying to get zone as string (e.g. EST/EDT) like this: merchantLocalReceiptDateTime.getZone().getDisplayName(TextStyle.SHORT, Locale.getDefault()) For my setup, it returns me EST while in fact I was expecting EDT.…
ror
  • 3,295
  • 1
  • 19
  • 27
1
vote
1 answer

Is the call to AndroidThreeTen.init() mandatory?

The ThreeTenABP README instructs users to isert a call to AndroidThreeTen.init() into their application’s onCreate() method. And yes, that’s the (supposedly faster) Android adaptation of ThreeTenBP, not the original (fully portable)…
user149408
  • 5,385
  • 4
  • 33
  • 69
1
vote
2 answers

Start and End of Week w/ ThreeTenBackport

I'm currently changing some code from Joda-Time to use Three-Ten Android Backport. All of the following methods take in a long as param and return a long Getting the end and start of the week with JodaTime was straight forward with…
Kyle
  • 695
  • 6
  • 24
1
vote
1 answer

How to easily switch imports sources in java?

NB: Please suggest a better title for this question. Suppose I have two classes with the same name and I want to import one or the other before I compile depending on the use-case/app version. Is there a way to do it ? Why do I need this ?, you may…
Ariles
  • 333
  • 1
  • 14
1
vote
1 answer

ThreeTenABP: DateTimeParseException

Trying to change date formats of a String but getting DateTimeException: String oldDate = "2018-12-18T17:04:56+00:00"; String outputFormat = "DD-MM"; try { Instant instant = Instant.parse(oldDate); LocalDateTime localDateTime =…
moyo
  • 1,312
  • 1
  • 13
  • 29
1
vote
0 answers

How do you use Three Ten Backport classes with JDBC?

I've been told that as of JDBC 4.2 we can directly pass java.time objects to the database. But what about the Three Ten Backport classes? Can you directly pass Three Ten Backport classes to JDBC as well? For example, let's say you pass an…
ktm5124
  • 11,861
  • 21
  • 74
  • 119
1
vote
1 answer

Not able to import classes from Three Ten Backport

This seems like a simple task, but I have already spoken with two of my co-workers about this and no one understands where the problem lies. We have a multi-module Maven project with a root POM file from which all the child modules inherit. In the…
ktm5124
  • 11,861
  • 21
  • 74
  • 119