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
3
votes
1 answer

ThreeTen toZonedDateTime: Exceptions when built by Ant

I have a unit test that throws an exception because it eventually calls DateTimeUtils.toZonedDateTime(cal); Setup We just recently started using the threeten-bp at our project. The lib is placed at a central project and the exception is thrown…
Torsten
  • 1,696
  • 2
  • 21
  • 42
3
votes
1 answer

Parsing a string into a ZonedDateTime with UTC timezone

How do you parse, using using the ThreeTen library (I can't use java 8) a string of the following format: 15 Aug 2014 forcing this to become a ZonedDateTime meaning 15 August 2014 in UTC timezone at midnight?
Edmondo
  • 19,559
  • 13
  • 62
  • 115
2
votes
1 answer

TzdbZoneRulesProvider not working in java.time

I'm migrating an old code base away from the threeten backport library to use java.time instead. There is a test method that no longer works, but I don't know how to fix it. Here is the class before the changes. This compiles correctly: import…
AndroidDev
  • 20,466
  • 42
  • 148
  • 239
2
votes
1 answer

How to stabilize flaky DateTimeFormatter#ofLocalizedDateTime test?

Given the following ThreeTenBp based DateFormatter: class DateFormatter private constructor() { private val dateShortTimeShortFormatter = org.threeten.bp.format.DateTimeFormatter.ofLocalizedDateTime( FormatStyle.SHORT,…
JJD
  • 50,076
  • 60
  • 203
  • 339
2
votes
2 answers

ZonedDateTime with timezone added to print format

I'm using https://github.com/JakeWharton/ThreeTenABP in my project. I have org.threeten.bp ZonedDateTime: 2019-07-25T14:30:57+05:30[Asia/Calcutta] How can I get this printed with addition of the timezone hours? ie the result should have…
nullUser
  • 1,159
  • 2
  • 15
  • 26
2
votes
1 answer

How to solve ExceptionInInitializerError and ZoneRulesException in ThreeTenABP?

I am trying to convert server time(GMT+09:00) to local time(any regions of client). I tried java.time. However, it requires at least minSdk API26. Then, I looked for alternative way So, I used ThreeTenABP library. I get this…
c-an
  • 3,543
  • 5
  • 35
  • 82
2
votes
1 answer

Getting error: from(java.time.Instant) in Date cannot be applied to (org.threeten.bp.instant)

I am trying to convert the org.threeten.bp.LocalDate to java.util.Date and I am getting the error mentioned in the question title. I am using following for…
AkshayT
  • 2,901
  • 2
  • 28
  • 32
2
votes
1 answer

Should you fully qualify the package prefix when using ThreeTen-Backport versus java.time?

We're using Three Ten Backport in our project, since one of our customers is using Java 7. Three Ten Backport gives us the new date-time functionality (java.time.*) introduced in Java 8. I'd like to know if the following is a good practice. Since…
ktm5124
  • 11,861
  • 21
  • 74
  • 119
2
votes
1 answer

How to properly use ThreeTenABP to get the time in milliseconds between two dates based on UTC

I'm using this library I just discovered which is supposedly less heavier than Joda time for android and I said what the heck, let's use it. But now I'm struggling to find any good examples on the web about how to use it, besides these two methods I…
user10217397
2
votes
2 answers

How to convert LocalDateTime to UTC and back, without loading zones?

Background I'm using threetenbp backport for Android (here), to handle various time related data operations. One of them is to convert a time to a different timezone (current to UTC and back). I know this is possible if you use something like…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
2
votes
1 answer

converting ZonedDateTime to Calendar using ThreeTen-Backport (JSR 310)

I am trying to convert a ZonedDateTime object to a Calendar object using the back-port of the java.time classes (JSR 310): the ThreeTen-Backport project. My understanding was that the back-port was supposed to be similar to functionality on Java 8…
Casey Harrils
  • 2,793
  • 12
  • 52
  • 93
2
votes
2 answers

How to fix ClassNotFoundException for org.threeten.bp.LocalDateTime?

Collegues, I built my project using mvn clean package and receive next stacktrace: 10:12:06.713 INFO [main] org.hibernate.Version - HHH000412: Hibernate Core {[WORKING]} 10:12:06.715 INFO [main] org.hibernate.cfg.Environment - HHH000206:…
May12
  • 2,420
  • 12
  • 63
  • 99
2
votes
1 answer

ThreeTenABP: How to validate date using a custom date format / DateTimeFormatter?

I'm using ThreeTenABP and seem to have run into a difference of implementation between LocalDate.parse(String) and LocalDate.parse(String, DateTimeFormatter). LocalDate.parse("31/02/1985", DateTimeFormatter.ofPattern("dd/MM/yyyy")) Parses to…
Tom
  • 6,946
  • 2
  • 47
  • 63
2
votes
1 answer

Unable to compile ThreeTenABP

I am trying to use Jake Wharton's ThreeTenABP library - https://github.com/JakeWharton/ThreeTenABP - for JSR310 date/time features in my Android project. This library's main advantage is that it has less compile overhead than Jodatime…
IgorGanapolsky
  • 26,189
  • 23
  • 116
  • 147
2
votes
1 answer

ThreeTen-Backport implementation vs. backport of JSR-310?

Note: this is not a duplicate of Comparing ThreeTen backport to JSR-310. My question is more specific. In my company, I'm trying to get DevOps to O.K. the use of ThreeTen-Backport for refactoring legacy code (which because of deployment constraints…
James Dunn
  • 8,064
  • 13
  • 53
  • 87