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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
54 views

Convert a UTC time to a local current time

I am using the followng library threetenbp I am fetching a date/time from our API response which is in string format The time I am being sent is this Sep 30, 2023, 4:59:00 PM So I need to convert that ...
ant2009's user avatar
  • 26.3k
2 votes
1 answer
76 views

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 ...
AndroidDev's user avatar
  • 20.6k
4 votes
1 answer
609 views

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 ...
ant2009's user avatar
  • 26.3k
1 vote
0 answers
29 views

org.threeten.bp zonedDateTime.parse does not work [duplicate]

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&...
BRDroid's user avatar
  • 4,052
3 votes
1 answer
1k views

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 ...
Morten Holmgaard's user avatar
0 votes
1 answer
760 views

Error org.threeten.bp.format.DateTimeParseException

I know that there is a lot of similar questions like this but cant apply these solutions on them. i am trying to transform date that i am getting from server int this format: 2019-07-26T02:39:32....
gojic's user avatar
  • 361
-1 votes
2 answers
1k views

error: incompatible types: Object cannot be converted to LocalDate

In my JSON response I receive the date as a timestamp value, e.g. below: "dt":1620345600 I am trying to convert this into a LocalDate using the ThreeTen BP library. I have tried to apply a ...
Murphler's user avatar
  • 125
0 votes
1 answer
379 views

Creating typeconvertor to convert Int timestamp to LocalDate

What would be the best way to go about this. I am using 2 different APIs and one returns a date as a String and the other returns date as an Int timestamp in the format of e.g. 162000360 I was using ...
Murphler's user avatar
  • 125
2 votes
1 answer
300 views

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....
JJD's user avatar
  • 50.5k
1 vote
1 answer
555 views

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 ...
goemic's user avatar
  • 1,102
0 votes
1 answer
635 views

Android error "org.threeten.bp.temporal.UnsupportedTemporalTypeException: Unsupported unit: Seconds"

I am using the 'com.jakewharton.threetenabp:threetenabp:1.2.4' library for using Newer features DateTimeFormatter for lower apis version. I have a situation where I have to first convert the the date ...
Hasnain Ghias's user avatar
0 votes
1 answer
494 views

Parse Date String Return Wrong Month

I try to parse date string but always get wrong month. Here's my code. This is code to select date from calender @OnClick(R.id.tedit_tgllahir_addnew) void showTimeDialog(){ calendar = Calendar....
Tiramochi's user avatar
1 vote
1 answer
1k views

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 ...
ryvantage's user avatar
  • 13.2k
0 votes
2 answers
1k views

How to modify decimal fractions from UTC Date Time to Date [duplicate]

I'm trying to convert a utc date time in local date time, but I have some problem the the decimal fraction. I call a web service the return a series of data. One of these data is the utc date time in ...
Scripta14's user avatar
  • 463
0 votes
1 answer
587 views

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 ...
c-an's user avatar
  • 3,643
1 vote
1 answer
1k views

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/...
Tapiwa's user avatar
  • 49
-2 votes
1 answer
188 views

What is the correct formatting pattern for this String format? [duplicate]

I am getting a DateTimeParseException when trying to convert a String to a ZonedDateTime with threeten. I am not sure what the correct formatting pattern is for this String format? 2014-04-16T00:00+02:...
Benny's user avatar
  • 861
3 votes
0 answers
333 views

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= ...
Khongor Bayarsaikhan's user avatar
6 votes
3 answers
7k views

How can I convert a org.threeten.bp.OffsetDateTime to java.time.OffsetDateTime?

I'm using a client library (third party, not mine, cannot change) which utilizes the ThreeTen date types. My project is Java 11 and uses Java 8 date types. What is the recommended way to convert ...
Fredrik Rambris's user avatar
0 votes
1 answer
799 views

How to parse time stamp and time zone offset simultaneously with Moshi?

A JSON-API-response contains the following properties: created_at_timestamp: 1565979486, timezone: "+01:00", I am using Moshi and ThreeTenBp to parse the time stamps and prepared the following ...
JJD's user avatar
  • 50.5k
1 vote
0 answers
354 views

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....
Chathura Wijesinghe's user avatar
3 votes
1 answer
635 views

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....
muetzenflo's user avatar
  • 5,605
1 vote
1 answer
1k views

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")); ...
Chris Knight's user avatar
  • 24.6k
7 votes
0 answers
2k views

org.threeten.bp.format.DateTimeParseException: Text could not be parsed at index [closed]

I'm receiving the date in the below format: "Deadline": "2019-07-05T16:30:00" And I'm trying to parse it using below formatter: private val formatter: DateTimeFormatter = DateTimeFormatter....
Aditya Tyagi's user avatar
3 votes
2 answers
1k views

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 ...
Bencri's user avatar
  • 1,181
1 vote
1 answer
975 views

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 ...
Justin Meiners's user avatar
2 votes
2 answers
737 views

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 ...
nullUser's user avatar
  • 1,169
1 vote
3 answers
483 views

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 ...
ror's user avatar
  • 3,340
0 votes
1 answer
701 views

What's the time format of now() in Threeten?

I use ThreeTen module and when I print ZonedDateTime.now(), I get. 2019-07-11T22:43:36.564-07:00[America/Los_Angeles] What's the format of this? I tried uuuu-MM-dd'T'HH:mm:ss.SSS'Z' and It says, ...
c-an's user avatar
  • 3,643
1 vote
1 answer
678 views

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, ...
user149408's user avatar
  • 5,463
0 votes
0 answers
30 views

how to edit threeTenAbp library

I'm using threeTenAbp library to create a calendar. but I need to change some codes in 'LocalDate.java', a class of threeTenAbp library. I clicked in 'copy path' and get this address: C:\Users\user\....
Mohammad Derakhshan's user avatar
2 votes
1 answer
372 views

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 ...
c-an's user avatar
  • 3,643
1 vote
2 answers
254 views

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 ...
Kyle 's user avatar
  • 695
2 votes
1 answer
2k views

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 conversion: Date.from(currentDate....
AkshayT's user avatar
  • 2,941
1 vote
1 answer
56 views

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 ...
Ariles's user avatar
  • 333
0 votes
0 answers
269 views

SimpleDateFormat creating 4 digit month

We have code very much like the code below where we take a java.util.Date and minus a certain amount of seconds from the date and store it as a string in a sqlite db: private static final String ...
Jeff's user avatar
  • 2,218
3 votes
1 answer
419 views

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: ...
Tyler's user avatar
  • 19.2k
7 votes
2 answers
2k views

How to initialize ThreeTen Android backport in a Unit test

I use this library for storing date & time related data in my app. When the application starts, AndroidThreeTen is initialized first to function properly. So I want to ask how to initialize it ...
Fawwaz Yusran's user avatar
1 vote
1 answer
1k views

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)...
moyo's user avatar
  • 1,322
1 vote
0 answers
43 views

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 ...
ktm5124's user avatar
  • 11.9k
2 votes
1 answer
189 views

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 ...
ktm5124's user avatar
  • 11.9k
1 vote
1 answer
513 views

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 ...
ktm5124's user avatar
  • 11.9k
10 votes
1 answer
3k views

How to unit test code which makes use of ZoneId.systemDefault without raising org.threeten.bp.zone.ZoneRulesException

I have the following application code. Application code public static long advanceByMax1HourWithoutOverflow(long currentTimeMillis) { ZoneId zoneId = ZoneId.systemDefault(); ZonedDateTime ...
Cheok Yan Cheng's user avatar
0 votes
1 answer
71 views

Conflicts while displaying dates in Android using ThreeTen

I have using ThreeTen in android for displaying 1-week dates from the current date. However, the problem is dates are not displaying in the correct order. Here's my code for days 1 week dates from ...
Lets Explorer's user avatar
0 votes
1 answer
609 views

Text could not be parsed at index 33

I am working on ThreeTenABP library to parse date and time. However, it is crashing. API I consume sends DateTime like; 2018-10-20T14:27:47.3949709+03:00 This is the way I try to parse; ...
nuhkoca's user avatar
  • 1,843
1 vote
2 answers
4k views

How to fix org.threeten.bp.format.DateTimeParseException?

I am converting UTC time into local time and I facing the error: org.threeten.bp.format.DateTimeParseException: Text 'Wed Oct 17 06:12:19 GMT+05:30 2018' could not be parsed at index 20 Please ...
Bala sundar k's user avatar
0 votes
1 answer
65 views

How to display local date type using recycle view in android?

I'm using the Threeten time zone to store the local date in a list of the LocalDate type. Here's my code : private List<LocalDate> getWeekDays() { ZoneId z = ZoneId.of("Pacific/...
Lets Explorer's user avatar
0 votes
1 answer
3k views

android.app.Application cannot be cast to android.app.Activity in fragment

I'm using Threeten time zone for fetching the date and time in android. But get an error at AndroidThreeTen.init((Application) getContext()); the error is "java.lang.ClassCastException: moneytracker....
Lets Explorer's user avatar
0 votes
1 answer
2k views

org.threeten.bp.format.DateTimeParseException: Text '2018-07-22T14:00:00-03:00' could not be parsed at index 19

public static String formatter(String dateInPattern, String dateOutPattern) { OffsetDateTime dateInPatternFormat = OffsetDateTime.parse(dateInPattern, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:...
Alan Bastos's user avatar
1 vote
0 answers
82 views

How to calculate minutes of the day from a UTC milliseconds value w/o time zone offset?

Given the following time stamp ... 2018-09-07T17:00:00+02:00 which corresponds to .. UTC: 1536332400000 milliseconds I like to calculate the amount of minutes of the day using the ThreeTen ...
JJD's user avatar
  • 50.5k