DSS-7, and the underlining libraries, allow the use of large dates, typically used in statistical analyses. It has been tested for years from –5,873,711 to 5,879,610, i.e., 01Jan-5873711 to 01Jan5879610 (that's over 11 million years). DSS-6 has a limit of from year 1,000 to year 4,800.


To accommodate these dates, the int timeGranularitySeconds in TimeSeriesContainer specifies what values in the TimeSeriesContainer times array represent. For regular size data sets, timeGranularitySeconds will match the set time granularity (although not guaranteed), which is 60 seconds for most datasets.

For large time span datasets that contain multiple records, timeGranularitySeconds may be returned as 3600 seconds (one hour) or 86400 seconds (one day).

This means that the times in the times array represent hours or days, not the default of minutes, so that those times do not overflow ints in the time array. (This is not to be confused with the time granularity in HecTime, nor the time granularity of how the times are actually stored in DSS (only minutes or seconds)).

This, along with the Julian base date, allow large ranges of dates for time series data.
HecTime objects can be set using an extended year, such as:


hecTime.setDate("01Jan5000000")
hecTime.setDate("01Jan-2000")


When using years less than 1000, keep the year to at least 4 digits with leading zeros (if needed). For example, the year 20 may have a date of "01Jan0020", and the year -5 would be "01Jan-005". All dates are based on a day count and do not include the 1500 era Gegorian Calendar changes.


When using extended datasets, be careful not to exceed memory. There are no established limits for DSS, but programs have a finite amount of memory.
An example of storing and reading an extended dateset follows.

Example: Irregular-interval time series data over 50,000 years

import javax.swing.UIManager;
import hec.dataTable.HecDataTableFrame;
import hec.heclib.dss.*;
import hec.heclib.util.HecTime;
import hec.heclib.util.HecTimeArray;
import hec.io.TimeSeriesContainer;

//  A simple snippit of code to demonstrate storing and retrieving 
//  dataset with very large time spans
//  Be carefull not to exceed memory space!
public class ExampleTimeSeries6 {

	public static void main (String args[])  {

		try {
			javax.swing.UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch (Exception ignore) {}

		
		//  Write a irregular interval data set.  Gen up the data and times
		//  We are going to be storing data from the year 1,000 to 55,758
		//  and store one value every 10 days for 2,000,000 values
		int numberValues = 2000000;
		TimeSeriesContainer tsc = new TimeSeriesContainer();
		HecTime hecTime = new HecTime("19Jan0201", "2400");
		HecTimeArray timeArray = new HecTimeArray(numberValues);
		double values[] = new double[numberValues];
		//  Irregular interval data requires the times array
		for (int i=0; i<numberValues; i++) {
			values[i] = (double)i;
			timeArray.setElementAt(new HecTime(hecTime), i);
			hecTime.addDays(10);  //  one value every 10 days	
		}		
		HecDataManager.setDefaultDSSFileName("C:/temp/Example7.dss");
		String pathname = "/Basin/Location/Flow//Ir-Century/Extended dates example 1/";
		tsc.setName(pathname);
		tsc.setUnits("CFS");
		tsc.setType("Inst-Val");
		tsc.set(values, timeArray);

		HecTimeSeries dssTimeSeries = new HecTimeSeries();
		int status = dssTimeSeries.write(tsc);
		dssTimeSeries.done();		
		if (status != 0) return;

		//  Read data
		TimeSeriesContainer tscRead = new TimeSeriesContainer();		
		tscRead.setName(pathname);		
		tscRead.retrieveAllTimes = true;
		HecTimeSeries dssTimeSeriesRead = new HecTimeSeries();	
		status = dssTimeSeriesRead.read(tscRead, true);
		dssTimeSeriesRead.done();		
		if (status != 0) return;

		//  Show in a table
		HecDataTableFrame tableFrame = new HecDataTableFrame(null);
		tableFrame.setData(tscRead);
		tableFrame.setVisible(true);
		
		HecDataManager.closeAllFiles();
	}
}

JAVA