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
5
votes
2 answers

Localized Date/Time with More Control

I am using the ThreeTen-Backport (specifically ThreeTenABP) to display a timestamp in my project. I would like the displayed timestamp to be displayed in a localized format (based on the Locale of the system); which is easy enough using either of…
Bryan
  • 14,756
  • 10
  • 70
  • 125
4
votes
1 answer

Formatting a date time string

I have the following date which we get from an API 2022-11-23 06:12:31 I am wondering if my approach is the best. And I need to display in this format 23 November 2022 I am using substringbefore to remove the time portion so I am left with the…
ant2009
  • 27,094
  • 154
  • 411
  • 609
4
votes
1 answer

How to use ThreeTen in Ant project?

I have some legacy Java 6 project and I want to bring some updates on them like Java 8 time library. I found that is possible by using ThreeTen backport. But I don't know how to use it with Ant build tool. Any good references or examples please ?
hoss
  • 113
  • 5
4
votes
2 answers

threetenbp: Parse exception when parsing date with time-zone name

I am trying to parse dates in the format of EEE, dd MMM yyyy HH:mm:ss zzz, so for example strings like "Tue, 16 May 2017 07:44:48 GMT" using threeten's DateTimeFormatter. However, it seems that the time-zone name can't get parsed for some reason (I…
hildegard
  • 559
  • 8
  • 24
4
votes
2 answers

Weird org.threeten.bp.DateTimeException thrown?

My code was working just fine. Today suddenly I started getting this exception - org.threeten.bp.DateTimeException: Field DayOfMonth cannot be printed as the value 1872095944 max width is 2 This is my simple code : LocalDateTime date =…
Ashwin
  • 12,691
  • 31
  • 118
  • 190
4
votes
2 answers

What's the best way to convert LocalDate and LocalTime to java.util.date?

I have a org.threeten.bp.LocalDate and a org.threeten.bp.LocalTime and I do need a java.util.date instance. Whats the best way to archieve this. I looked through DateTimeUtils but found no proper solution.
Lukas Lechner
  • 7,881
  • 7
  • 40
  • 53
4
votes
2 answers

ThreeTen and parsing an Instant

I'm using ThreeTen and attempted to format an Instant. Would be easier to just split it but I'm curious, should this work? From everything I've read Instant should be parse-able, and with all the components of the pattern: @Test public void…
user1351848
  • 127
  • 1
  • 1
  • 9
3
votes
1 answer

Jetpack Compose Preview failing with LocalDate.now() from ThreeTen

Rendering the Jetpack Compose Preview fails when we have some code calling LocalDate.now() from it. We have tried setting a locale on the preview but that does not help, and we have not found any other way to set context information on the…
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
2 answers

Convert a timestamp before year 1900 in java

My Android app communicate with an API which give me the following timestamp : -2209161600. Converted to a date time, it's supposed to be 12-30-1899 00:00:00 The problem is, I tried to convert this timestamp using both the default library,…
Bencri
  • 1,173
  • 1
  • 7
  • 22
3
votes
1 answer

ThreeTen Backport causing runtime only on some devices

Does this trace look familiar to anyone? It's only happening on a handful of devices. ThreeTenBP is a dependency in a dependency. 10:16:33 E AndroidRuntime : java.util.ServiceConfigurationError: org.threeten.bp.zone.ZoneRulesProvider: Provider…
Tyler
  • 19,113
  • 19
  • 94
  • 151
3
votes
2 answers

How to deserialize ThreeTen LocalDateTime in Retrofit?

I'm trying to deserialise this class in Retrofit: data class Measurement(val id: Long, val value: Float, val dateTime: LocalDateTime, val trashCanId: Long) : Parcelable { companion object { @JvmField val CREATOR:…
Leandro Borges Ferreira
  • 12,422
  • 10
  • 53
  • 73
3
votes
2 answers

LocalDateTime.now() crashes on Sony Bravia

I am using the ThreeTen Android Backport in an app for AndroidTV. While everything works perfectly on the Nexus Player and on all tested Amazon Fire TV devices, the call to LocalDateTime.now() consistently crashes the app on a Sony Bravia 4K 2015…
david.mihola
  • 12,062
  • 8
  • 49
  • 73
3
votes
1 answer

Best way to convert org.threeten.bp.* and org.joda.time* to corresponding java.time.* class

I am working on a project that uses a shared library which uses org.threeten for Date/Time. As the library is shared across many projects it cannot be upgraded to Java 8 yet (sigh). The shortest way seems to be toString()/parse()…
klor
  • 3,596
  • 2
  • 13
  • 13