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

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

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

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

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.

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

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.

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

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.