Link to home
Start Free TrialLog in
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
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of AndyC1000
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
Avatar of dpearson
dpearson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial