Skip to content
Advertisement

Tag: duration

Best practice for time dependent variables

I have a system that operates with real-time events. The user can interject custom events at a specified interval. The real-time engine uses java.time.Duration to time the events. The user is presented a menu via jsp that has a specification of the Duration in (whole) seconds. The event list is serialized as Long values. So I have three ways of

why nano seconds have to use int instead of long in java

I have been doing this exercise and this is the code Doesnt nanoseconds have to use long instead of int because the nanoseconds in the range? Answer That’s because like documentation says, we have a duration which consist of two fields, one is seconds and the other one is nanos. So when you ask for duration between, you get 2

Random time and date

I want to get a date that generates the time from now to 2685 days back and a random time. The format I accept must be “uuuu-MM-dd’T’HH: mm: ssZ”. Currently my program is generating a random date but I am not able to create a random time because Duration conflicts with Period Answer Something like this may be?

Read a time from file in java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. Improve this question I am doing a work for the university and I have to read many lines from file a with that format: 3ld4R7 4:27 3475 Everything is

Time difference in AM/PM in Java

I am trying to calculate the time difference in java by input time format in 12 hours it works well when i input start time 11:58:10 pm and end time 12:02:15 am. But as i enter 12:00:00 am and 12:00:00 pm it give difference 0 minutes. don’t know why. Below is my code please let me know where i am

Summing up times using Duration

For my project, I have to read in data that is given to us in a CSV file and write it out in a certain format. I have it almost done but the problem I am having is that my program is not completely reading through the times that are given. From here my program is just reading all the

SimpleDateFormat returns wrong number of days

I need to get the number days, hours, minutes, seconds from a long value. But I am getting wrong number of days from a following code. When I pass 106988550 and “dd:HH:mm:ss” to this method, I am getting “02:05:43:08” Expected actual answer is : “01:05:43:08”. I don’t know where it is wrong and how I can achieve the actual answer.

Convert seconds into T1H15M5S (ISO_8601)

I would like to convert a number of seconds into ISO_8601/Duration in Java. http://en.wikipedia.org/wiki/ISO_8601#Durations Are there any existing methods to do it that are already built in? Answer Since ISO 8601 allows for the individual fields in a duration string to overflow, you could just prepend “PT” to the number of seconds and append “S”: This will output “PT4711S”, which

Advertisement