Skip to content
Advertisement

Tag: time

java Program runtime is too fast? Issue with Memory

So I am running some simulations that require some sample datasets. For the sake of simplicity I am using this http://loremipsum.sourceforge.net/ Lorem Ipsum generator. I am setting a test parameter called DATASIZE that sets the amount of words or paragraphs this generator creates. I am using this generated data to create an “input” and “output” hash. The output data will

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

How to print times (hh:mm) in a quarter-hour cycle?

I need to basically print every quarter-hour of the day from 00:00 to 23:45 (so 96 different times) in hh:mm format to create a html report. Is there a standard library to do that? Or another way? Answer Can be done using the java.time.LocalTime: It can also be done with a for loop, just consider that LocalTime does not accept

Handle daylight savings time and representing UTC in Date object

I have a function which returns the current UTC time in Date object, simple. What we do is find current Instant of UTC, put it in Date object and return. Note: Local Host time here is New York/America. The problem we are now facing is that Date refuses to store March 13 2:02 AM, since the time doesn’t exist (clocks

How to convert Date string into UTC Date object?

I’m learning Java and come across this issue. I have a date string with the given format. Now I wanted to initialize/create a Date object of UTC timezone. For this, I have tried below code This will convert the time into UTC instead of just creating a date object. Now I’m confused as to which is the correct approach to

Converting Time Zone to GMT values in Java 11

We keep time zones of the cities in our config table using ID of Time Zone values as Europe/London, Asia/Tokyo, etc. However, when selecting time zones from the list, user needs to see the GMT values for these time zones and we want to display Display Name of Time Zone Options as (UTC+00:00) Dublin, Edinburgh, Lisbon, London rather than Europe/London.

Advertisement