Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
27 views

Not able to serialize ZonedDateTime and PeriodDuration while converting a bean to XML

I used Joda-Time earlier. Now, I have migrated from DateTime(Joda-Time) to ZonedDateTime(java.time). I have also converted Period(Joda-Time) to PeriodDuration(Java). But as ZonedDateTime and ...
Saurabh Sole's user avatar
0 votes
1 answer
352 views

OpenRewrite recipe to migrate Joda to Java 8 time?

Since Java 8, Joda time has been replaced by the standard java.time APIs. Is there a OpenRewrite recipe that does that automatically? Especially in a big codebase, the task can prove tedious to be ...
Daniel Pop's user avatar
0 votes
1 answer
85 views

How to migrate Joda time Period API to Java time (java 8)?

I want to migrate JODA time period API to JAVA time (java 8). Joda time period API supports both time and date.eg. It supports from milliseconds to year. But in java.time we have 2 separate ...
Saurabh Sole's user avatar
-1 votes
2 answers
1k views

Set empty value for ZonedDateTime [closed]

I want to migrate this code from Joda-Time to its replacement, java.time (JSR 310). Specifically I want to use ZonedDateTime. Old code: DateTime startTime = new DateTime(); DateTime stopTime = new ...
Peter Penzov's user avatar
  • 1,738
1 vote
1 answer
93 views

Migrate org.joda.time.Duration to java.time.Duration

I want to migrate this java based on joda library to java.time import org.joda.time.DateTime; import org.joda.time.Duration; import org.joda.time.Instant; private DateTime createdDate; private ...
Peter Penzov's user avatar
  • 1,738
1 vote
2 answers
138 views

How to format only one offset but support mutiples offsets with DateTimeFormatterBuilder with a migration from joda?

I want to migrate my code from Joda to java.time. I use DateTimeFormatter for parsing and formating multiple date. The problem is with DateTimeFormatter.format(...), the return String is "2023-02-...
kevin h's user avatar
  • 11
3 votes
1 answer
588 views

Converting Joda DateTime to JavaTime

I am trying to update my existing elasticsearch springboot project and as the source code is fairly old it still uses joda time. Now I have to upgrade all the functions of Joda time to java time. Now ...
Umang Pachaury's user avatar
1 vote
1 answer
135 views

Why JodaTime Library and JDK OffsetDateTime report Pacific/Norfolk time zone offsets as different? Which one is correct?

public static void main(String[] args) { System.out.println("Norfolk Island times as per Joda Time"); IntStream.range(1, 13) .forEach(month -> System.out.println(...
Rajkishan Swami's user avatar
-2 votes
1 answer
611 views

Converting from Joda to Java time

I need to convert joda time to Java time but having some issues My joda time code : p.s method is a long type (long argDateString) DateTime istime = new DateTime(argDateString*1000); DateTime ...
Random Things's user avatar
0 votes
3 answers
1k views

Issue in fetching Local time with Java 8 Time API with particular pattern of date

I am having difficulty in finding the current time in some pattern with JAVA 8 time api. I am trying below code for this, my goal is to find time in this pattern only -> yyyy-MM-dd'T'HH:mm:ss.SSS'Z'...
user avatar
4 votes
1 answer
6k views

How to convert Instant to joda DateTime?

How to convert Instant(java.time.Instant) to joda DateTime (org.joda.time.DateTime)? Or rather, what's the best way to do this?
Saif's user avatar
  • 3,352
2 votes
1 answer
285 views

Is this a bug in joda time? Handling very old (year 0000) instant / negative epoch

It seems like DateTime does not initialize itself with correct date when we construct it from a java.util.Date with year 0001. import java.time.LocalDateTime; import java.util.TimeZone; public class ...
Kashyap's user avatar
  • 17k
0 votes
1 answer
270 views

Swagger: Converting Java LocalDateTime to Joda LocalDateTime

I converted Java LocalDatetime to Joda LocalDateTime all around my program. Now my Swagger request json is causing 400 response header errors. How do I resolve for this in Swagger? This was original ...
mattsmith5's user avatar
0 votes
2 answers
651 views

Default locale in joda time vs. java time

I have recently changed from org.joda.time package to java.time package and I am wondering how the two differ in using a default locale. Locale is used when parsing dates; the java.time seems to use ...
Stumpp's user avatar
  • 289
2 votes
1 answer
494 views

Joda time - get next time it's X o'clock

I need to get the next datetime when it's say, 20.00 o'clock. So for instance, if it's 13.00 hours, it'd give me the datetime corresponding to today at 20.00. But if it's 21.00, it'd give me tomorrow ...
rutchkiwi's user avatar
  • 486
0 votes
1 answer
709 views

JodaTime and Daylight saving time

I develop a custom schedule calendar, with 30 minutes gap, so when i generetae this by adding 30 minutes: date = date.plusMinutes(minuteStep) so in moment when our time zone switch to Daylight saving ...
Александр Волошиновский's user avatar
2 votes
1 answer
128 views

For Some Timezones, Corrected Time after setting TimeZone via JodaTime and java.time are giving different results, Why?

Following is a small code snippet in java trying to convert a time in millis to a readable date time format, Long timeInMillis=1615806808301l; //2021-03-15T16:43:28.301+05:30 IST String timeZone=&...
Fredric Francis's user avatar
0 votes
1 answer
913 views

convert from org.joda.time.LocalDateTime to java.sql.date

I've this code LocalDateTime localDateTime = LocalDateTime.parse("1777-11-11T00:00:00.000"); System.out.println("DateTimeZone.getDefault default" + DateTimeZone.getDefault()); ...
Romeo Velloni's user avatar
1 vote
1 answer
3k views

How to parse ZonedDateTime with milliseconds [duplicate]

Jira is giving me this date format via Rest API: 2021-01-21T11:08:45.000+0100 How can i parse this to a LocalDateTime in Java? I tried ZonedDateTime.parse("2021-01-21T11:08:45.000+0100", ...
Thomas Lang's user avatar
  • 1,465
2 votes
1 answer
819 views

Algorithm used by java.time.Period.between() when dealing with different-length months?

When using java.time.Period.between() across months of varying lengths, why does the code below report different results depending on the direction of the operation? import java.time.LocalDate; import ...
Justin Grant's user avatar
  • 46.5k
1 vote
2 answers
643 views

Joda Time Returns Correct Date, but Java Time Doesn't

I support a large enterprise app and we have two classes that use LocalDate.now to get a timestamp, one uses joda time, one uses Java time. Typically we restart every night, but earlier this week we ...
K R's user avatar
  • 21
0 votes
1 answer
514 views

Java - get unix epoch with microsecond

I am struggling to get the unix time epoch with microseconds in this format(1586420933.453254). I tried different classes. - java.utils.Calendar - java.time.Instant - org.joda.time.DateTime But I am ...
SKK's user avatar
  • 1,719
0 votes
1 answer
423 views

Migration from org.joda.time.Interval in Spring Boot

I used to apply org.joda.time.Interval to represent a time interval with fixed start and end times (different from a duration which is independent from specific times) to exchange via REST and store ...
SaschaH's user avatar
  • 361
1 vote
0 answers
655 views

Replacing joda time with time api in hibernate entity

I am currently upgrading from jodatime to the javatime api in a project. The project is using hibernate version 4.3.1 and jadira.usertype for mapping between org.joda.time.DateTime and java.sql....
peanut_butter's user avatar
2 votes
1 answer
715 views

Not able to convert from HH:mm:ss.SSS'Z' to HH:MM format Java

I'm trying to convert into HH:MM format in Java Here is my code String date = "18:30:00.000Z"; try { ZonedDateTime parsed = ZonedDateTime.parse(date); ZonedDateTime z = parsed....
Syed's user avatar
  • 2,587
0 votes
2 answers
362 views

Convert Date and Time with different timezones to timestamp

got a little problem in Java: I've got two strings, representing a date (for example "2019-11-10") and a time (for example "01:23:45.123"). Converting those into a UTC timestamp is easy enough, but ...
Florian Schaetz's user avatar
2 votes
2 answers
360 views

Converting JodaTime Duration to Java 8 time Duration: getStandardMinutes and other methods

We're trying to convert a product that we have written using Joda-Time library to Java time due to some time zone wonkery in our country. (Daylight Saving Time DST is never consistent, and Joda-Time ...
Sebastian's user avatar
  • 795
4 votes
2 answers
3k views

How can I convert a Joda's Duration to a java.time.Duration?

I want to parse a string like 1d2h3m4s into a java.time.Duration. I can use a joda's PeriodFormatter to parse the string into a org.joda.time.Duration but I can't figure out how to convert that to a ...
RubenLaguna's user avatar
  • 24.3k
0 votes
2 answers
531 views

Setting time zone offset in java 8 time versus joda time

I work for an organization in two locations. One of them is Chile, where daylight savings time is extremely unpredictable and often varies from year-to-year. We have an application that is dependent ...
Sebastian's user avatar
  • 795
1 vote
2 answers
976 views

Java8 equivalent of JodaTime DateTimeFormat.shortDate()

What is the Java8 java.time equivalent of org.joda.time.formatDateTimeFormat.shortDate() I've tried below way, but it fails to parse values such as "20/5/2016" or "20/5/16". DateTimeFormatter....
wilmol's user avatar
  • 1,860
3 votes
1 answer
343 views

Need non-proleptic Gregorian chronology in Java 8 (like org.joda.time.chrono.GJChronology)

I dont see the equivalent java.time.Chronology to org.joda.time.chrono.GJChronology.java, that is, a non-proleptic Gregorian Calendar ("the Gregorian/Julian calendar system which is the calendar ...
John Caron's user avatar
5 votes
4 answers
8k views

TimeZone.getTimeZone("PST") vs TimeZone.getTimeZone("America/Los_Angeles")

I'm Using Java 8, Earlier in our code, We were using sdf.setTimeZone(TimeZone.getTimeZone("PDT")); to convert to US Pacific which was failed(not throwing any errors but converted to default ...
PrabaharanKathiresan's user avatar
1 vote
4 answers
3k views

Are methods DateTime.now() and new DateTime(System.currentTimeMillis()) equal in java?

I need to know, in java(my version jdk 8), i can replace, new DateTime(System.currentTimeMillis()) this code form , 'DateTime.now()' ? I used package import org.joda.time.DateTime; How write this ...
uma's user avatar
  • 1,557
1 vote
1 answer
197 views

Joda Time - repeating/weekly Interval

I want to convert a string like the following to an object that can evaluate an instant to be withing a periodic interval or not: Mon: 0800-1300 I am looking for some kind of functionality that I ...
Salocin's user avatar
  • 403
2 votes
0 answers
505 views

How to deserialize array of Joda-Time LocalDate to java.time LocalDate?

Since recent migration to Java 10, we are also considering replacing Joda-Time by java.time classes in our codebase. A big obstacle is handling the existing serialised Java objects which have array of ...
qingl97's user avatar
  • 347
2 votes
2 answers
3k views

Why get different localDate with same timezone

java.sql.Date date = java.sql.Date.valueOf("1900-01-01"); org.joda.time.LocalDate localDate = new org.joda.time.LocalDate(date); Based above code, I did some tests as below: Question #1 why do I get ...
Haven Lin's user avatar
  • 176
3 votes
1 answer
2k views

Joda-Time to java.time migration 'fromDateFields()'

We are currently migrating from Joda-Time to java.time. I have the following doubts about the fromDateFields()method. Old joda code: Date date = new Date(); //some java Date LocalDateTime lt = ...
Lonzak's user avatar
  • 9,796
5 votes
1 answer
3k views

Pattern "YYYY-MM-dd HH:mm:ss Z" causes parsing exception where Jodatime did not

I am trying parse ZonedDateTimes from Strings in the following format: 2017-08-10 16:48:37 -0500 I had previously done so successfully using Jodatime's DateTimeFormat.forPattern("YYYY-MM-dd HH:mm:ss ...
kes's user avatar
  • 6,167
7 votes
4 answers
641 views

Joda-time off-by-one error when counting days after 1918-03-24

Calculating the number of days between 1900-01-01 and a date after 1918-03-24 using Joda-Time seems to give an off-by-one result. Using Java 8 java.time gives the correct result. What is the reason ...
Chro's user avatar
  • 1,003
14 votes
2 answers
5k views

DateTimeFormatter weekday seems off by one

I'm porting an existing application from Joda-Time to Java 8 java.time. I ran into a problem where parsing a date/time string that contains a 'day of week' value triggered an exception in my unit ...
Niels Basjes's user avatar
  • 10.6k
0 votes
0 answers
215 views

Eclipse Organize Import converts Joda time to java.time for Java 8

When I run a full organize import converts the following imports: import org.joda.time.LocalDate; import org.joda.time.LocalDateTime; to: import java.time.LocalDate; import java.time.LocalDateTime; ...
Serkan Kaba's user avatar
2 votes
2 answers
1k views

UTC to local method in DateTimeZone of Joda-Time to Java 8

We are changing Joda-Time API's to Java 8 time API's. In Joda-Time I have used: DateTimeZone.convertLocalToUTC(this.getMillis(), true); DateTimeZone.convertUTCToLocal(long millis); Can any one tell ...
wazza's user avatar
  • 810
10 votes
1 answer
10k views

Joda-Time to Java 8 conversion

How can I achieve the following in Java 8 java.time: DateTime dt = new DateTime(year, month, date, hours, min, sec, milli); But I have found this option: OffsetDateTime.of(year, month, dayOfMonth, ...
wazza's user avatar
  • 810
3 votes
2 answers
2k views

How to find n'th previous Sunday with Java date time API or Joda-time?

How do we calculate previous Sunday or previous to previous Sunday or in general lets say how to find out sunday prior to n weeks? The catch is if today is Sunday then it should return today as Sunday ...
java brain's user avatar
0 votes
0 answers
458 views

Scala : UTC to Local time based on ZoneId

I am trying to convert UTC timestamp to local time based on Country Code (2 digit) . Can some one tell me which time function I should use here? Couldn't find any proper examples. import org.joda....
user3407267's user avatar
  • 1,614
0 votes
0 answers
190 views

Java 8 ZonedDateTime strips off .SSS if they are zeros [duplicate]

For whatever reason, ZonedDateTime in jdk 8 is removing .SSS values from the object if they are zeros. This did not happen with joda-time's DateTime object. String date = "2016-10-28T02:32:12.141"; ...
Peadar O'Maoileoin's user avatar
4 votes
1 answer
8k views

What is the best way to convert a org.joda.time.DateTime to a java.time.OffsetDateTime?

The following works, but it seems a little clumsy to convert the time to a long, and then an Instant as well as converting the timezone to a TimeZone and then a ZoneId. Is there a cleaner way to do ...
Alex Spurling's user avatar