Questions tagged [threetenabp]

ThreeTenABP is an adaptation of the JSR-310 backport for Android. Note that questions about "java.time" in Java SE 8 should use the [java-time] tag, and non-Android ThreeTen-Backport questions should use the [threetenbp] tag.

ThreeTen Android Backport is an adaptation of the JSR-310 backport for Android.

14 questions
230
votes
3 answers

How to use ThreeTenABP in Android Project

I'm using Android Studio 2.1.2 and my Java setup is the following: >java -version > openjdk version "1.8.0_91" > OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~15.10.1-b14) > OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode) I…
kael
  • 6,585
  • 5
  • 21
  • 27
26
votes
2 answers

How to convert ZonedDateTime/OffsetDateTime to Date using ThreeTenABP?

Using the ThreeTen Android Backport library, what is the simplest way to convert a ZonedDateTime or OffsetDateTime into an old-school java.util.Date instance? If I had full Java 8 libs at my disposal, this of course would be the way to do it (as in…
Jonik
  • 80,077
  • 70
  • 264
  • 372
5
votes
2 answers

How do I calculate age from my date picker?

I am learning Kotlin on my own. I am trying to calculate the age of a user after the have input their date of Birth and display it in another activity. I tried a bunch of different stuff and none worked. I'm sure I maybe overlooking something…
Shane.B
  • 53
  • 3
3
votes
0 answers

Gradle sync error: Duplicate key AdditionalClassifierArtifactsImpl

I'm building an Android project. When I open my the project, during the gradle sync, I keep getting the following error message: Duplicate key AdditionalClassifierArtifactsImpl( id= ArtifactIdentifierImpl(groupId=org.threeten,…
Khongor Bayarsaikhan
  • 1,644
  • 1
  • 16
  • 19
3
votes
1 answer

How to setup and use ThreeTenABP library

I can't get ThreeTenABP to work. Here's what I did: import dependency in app build.gradle implementation 'com.jakewharton.threetenabp:threetenabp:1.2.1' initialize the library in MyApplication.onCreate() AndroidThreeTen.init(this) add…
muetzenflo
  • 5,653
  • 4
  • 41
  • 82
3
votes
1 answer

How to make LocalDate and LocalTime parcelable?

I am new to android, and making a doctor's appointment managing android app using ThreeTenABP's (so it's compatible with more devices) LocalDate and LocalTime, which I need to make parcelable. I have the parcelable complex class Appointment, which…
2
votes
1 answer

android: Desugaring of ZonedDateTime results in TimeOffset being null

I'm trying to migrate from ThreeTen Android Backport to java.time with desugaring. On debug builds this works perfectly, but on release builds (minifyEnabled = true) I get a weird error on runtime. After a ZonedDateTime is serialized (passing a…
goemic
  • 1,092
  • 12
  • 24
2
votes
1 answer

ThreeTenABP DateTime parser giving exception for yyyy-MM-ddTHH:mm:ss formate

I need to convert a dateTime String to millis and I am using ThreeTenABP for this, but the OffSetDateTime.parse is unable to parse the dateTime String which is for ex. "2020-08-14T20:05:00" and giving the following exception. Caused by:…
RKB
  • 106
  • 10
1
vote
2 answers

DateTimeParseException at index 0 with ThreeTenABP

I'm trying to parse a time string with ThreeTenABP (because I have to support min SDK 19). I think the string is ISO 8601: 20200117T172638.000Z I get the following exception: org.threeten.bp.format.DateTimeParseException: Text '20200117T172638.000Z'…
user10981072
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
0
votes
1 answer

org.threeten.bp.format.DateTimeParseException: Text 'Sat Sep 19 2020 07:14 AM PDT' could not be parsed at index 25 at $.root.bsa[0].posted

I'm trying to parse a date that looks like: Sat Sep 19 2020 07:14 AM PDT into a ZonedDateTime. I'm using this formatter DateTimeFormatter.ofPattern( "EEE MMM dd yyyy hh:mm a zzz", Locale.US ) and I'm attempting to convert the String…
Jonathan Chiou
  • 349
  • 6
  • 15
0
votes
1 answer

parsing DateTime with ThreetenBp causes DateTimeParseException or incomplete string error

I am trying to check if the date has passed more than one day or not. And I got these errosr while it parses the string. java.lang.IllegalArgumentException: Pattern ends with an incomplete string literal:…
c-an
  • 3,543
  • 5
  • 35
  • 82
0
votes
2 answers

java.time format date depending on locale with 2 digits day/month and 4 digits year

I need to show a date with 2 digits day, 2 digits month, 4 digits year according to the order of the local. So for April 10th 2020 I want to show for locale US: MM/DD/YYYY -> 04/10/2020 for locale UK: DD/MM/YYYY -> 10/04/2020 for locale DE…
stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270
0
votes
2 answers

org.threeten.bp.format.DateTimeParseException

val dateFormatter= DateTimeFormatterBuilder() .appendPattern("yyyy-MM-dd") .toFormatter() val begin = (LocalDateTime.parse("2019-11-04", dateFormatter).atOffset(ZoneOffset.UTC) …
ghita
  • 2,746
  • 7
  • 30
  • 54