Questions tagged [time4j]

Concerns questions directly related to the alternative date, time and interval library Time4J.

Its API can be either used as enhancement for missing features centered around time and calendars or as replacement of java.time-package on Java-8. There is also a backport available when running on platforms Java-6+7 (using version line v3.x).

The design is mainly orientated towards:

  • thread-safety (immutability)
  • good internationalization (own resources based on CLDR-data)
  • accurate modelling of alternative calendars, historic dates, leap-seconds etc
  • easy conversion and interoperability with java.time-classes
  • extensive interval handling

The source code and issue tracker can be found on GitHub. The API and tutorial are available online under: time4j.net

A sister project named Time4A is very similar but designed for the usage on the Android platform.

25 questions
6
votes
1 answer

How to convert time 24-hour to AM/PM and remove nanoseconds & seconds via time4j?

I'm faced with the issue that I need to convert time from 24 format to AM/PM format (and vice-versa) removing redundant values such as nanoseconds and seconds by time4j library. I'm using the time4j library because Java can't handle Windows Time…
5
votes
2 answers

How to get current date in time4j library?

how I can get current Persian Date with time4Jin java? PersianCalendar jalali = new PersianCalendar();
MOHS3N
  • 159
  • 1
  • 1
  • 11
4
votes
1 answer

How to get sum of all time duration in an array in Java?

I have an array of duration stored as a string. [0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:0, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00, 0:00:00,…
Hansie
  • 143
  • 1
  • 6
4
votes
1 answer

Get week in month in hijri calendar in time4j

I'm trying to set hijri calendar to for example 3rd Wednesday of hijri months. After some search, I reach to this code: PlainDate date = PlainDate.of(2017, 3, 1); // first of march 2017 …
max
  • 5,014
  • 11
  • 37
  • 66
3
votes
1 answer

javafx open window no effect.application launch with then throw class not found

Ok,so for starting a javafx app,we need to launch the javafx app. Then by right if we want to add a new window we can just simply do stageobj.show(); right? Below is part of my code,that I tried to create the new window.I already launch my app and…
3
votes
2 answers

How can I change the font of the Time4J CalendarPicker in JavaFX?

Is there a way to change the font of Time4J CalenderPicker in css-style? I needed a Persian DatePicker in my program so i used Time4J CalenderPicker. using this code i could change only the font of cells: CalendarPicker MyDatePicker…
Ahmad
  • 77
  • 5
3
votes
1 answer

Formatting time4j moment

For one of the projects, I was given a millisecond from another system. I need to convert to "yyyy-DDDT:HH:mm:ssZ" The trick is to display it in leap-second. Since Java libraries does not have leap-second, I decided to use Time4J's Moment class.…
william
  • 6,206
  • 18
  • 60
  • 99
2
votes
2 answers

How to use PrettyTime in time4j library?

I am receiving a text which is in seconds (e.g. 7261). I need to convert it to this format: 2h, 1m, 1s I am using time4j library. According to their Github page, I am doing something like this: val duration = Duration.of(7261,…
Mehdi Satei
  • 605
  • 4
  • 17
2
votes
1 answer

Formatting Chinese converted date by time4j to Gregorian in Java

I am working on a project in Java and I need to change different types of dates to each other like (Gregorian to Chinese and vice versa and Gregorian to Hijri and vice versa). I try to use Time4j which has this facility to convert different types of…
Ali Ansari
  • 132
  • 1
  • 1
  • 11
2
votes
1 answer

How can I convert timestamp to time4j Moment format?

I have a problem with Time4J library, I can not convert specific timeStamp to Moment format. for example, I want something like this: Moment.timeInMillies = myTime or Moment.of(myTime) myTime is a long value of milliseconds since the epoch, which…
Amir Hossein Ghasemi
  • 7,952
  • 4
  • 43
  • 42
2
votes
1 answer

Define a date range in Time4j (Persian calendar)

I want to define a date range like this: start from "1396/8/9" end to "1396/9/2" And get the days date between these two dates. I searched through the Internet and I found a DateInterval function in Time4j. Is it possible to use this method for…
Sameer
  • 55
  • 7
2
votes
1 answer

Add duration to a moment using time4j

As I am converting code using the java.time implementation to time4j, I want to add a Duration to a Moment but I get a compilation error. Under java.time, I would do the following: val startTime: ZonedDateTime = ... val duration: TemporalAmount =…
jlr
  • 928
  • 6
  • 16
1
vote
2 answers

How can I fix the NoSuchMethodError from the Time4J Library?

I'm having throble with NoSuchMethodError in this line of my code: private CalendarPicker calendarPicker = CalendarPicker.persianWithSystemDefaults(); It works fine when I run the project in intellij idea but the output jar…
Ahmad
  • 77
  • 5
1
vote
1 answer

Iterating recurring timestamps for a given range in Time4j

I am using Time4j to parse recurring intervals like this: IsoRecurrence.parseTimestampIntervals("R/2019-01-01T00:00:00/P1D") This will give me an iterator with infinite number of daily recurring instances starting from the beginning of 2019. Is it…
Arho Huttunen
  • 806
  • 6
  • 15
1
vote
2 answers

Converting time4j Duration from P365D to P1Y and so on

Instant i1 = Instant.now(); Instant i2 = Instant.now().plusSeconds(60 * 60 * 24 * 365); Duration dur = Duration.from((TemporalAmount) java.time.Duration.between(i1, i2)); System.out.println(dur); this code prints P365D, is there a way to…
1
2