Avatar of AndyC1000
AndyC1000
 asked on

Java generate and store half hourly time steps from start to end date

Dear all,

I'm trying to convert an excel model into java.  I need to generate half hourly time steps based on a start and end date provided by the user and store into a data structure.  I've converted the date into simple date format dd-MM-yyyy.  What is the most efficient way to generate this data and store in the data structure below?

I've decided to store the data in nested Maps, i.e. (if there is a better way let me know...).  Weather is an example of one set of data, there are 5 others that will need to be accessed in the same way.

Map<Date, Map<String, double>> weatherMap = new HashMap<Date, HashMap<String, double>>();

The inner map contains the timestep as key, and weather data as value.  The outer map will contain the date as key and the inner map as value.

I've defined the timestep value as type string, not sure if it should be double?

Thanks
Java

Avatar of undefined
Last Comment
dpearson

8/22/2022 - Mon
CEHJ

If there are no 'holes' in the data, then the keys are redundant as the correct data point can be determined by calculation. All that's needed is start date, end date and a list of doubles
AndyC1000

ASKER
I need to be able to store the data there will be a number of calculations based on a date/ timestep.  For each date/time step I will be running a calculation 1000 times (monte carlo).
ASKER CERTIFIED SOLUTION
dpearson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
CEHJ

I need to be able to store the data there will be a number of calculations based on a date/ timestep.  For each date/time step I will be running a calculation 1000 times (monte carlo).
I still  don't see why you'd need to store anything, other than perhaps the results of the calculations
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
AndyC1000

ASKER
Thanks.  I understand now why the date is redundant didn't know long values contained date info.

I'm not sure what you meant by the below rounding off instead of truncating.
You'll still need to write the code to do the lookup - which is similar but rather than truncating to the nearest hour, you need to round off to the nearest 30 mins.
SOLUTION
dpearson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.