cdm/src/main/java/ucar/nc2/iosp/grads/GradsTimeDimension.java
protected double[] makeLevelValues() {
        List<String> levels = getLevels();
        if (levels == null) {
            return null;
        }
        if (levels.size() != getSize()) {
            // do someting
        }
        // Time is always LINEAR
        int      inc     = 0;
        double[] vals    = new double[getSize()];
        String   tstart  = levels.get(0).trim().toLowerCase();
        String   pattern = null;
        if (tstart.indexOf(":") >= 0) {                     // HH:mmZddMMMyyyy
            pattern = dateFormats[0];
        } else if (tstart.indexOf("z") >= 0) {              // mmZddMMMyyyy
            pattern = dateFormats[1];
        } else if (Character.isLetter(tstart.charAt(0))) {  // MMMyyyy
            pattern = dateFormats[3];
        } else {
            pattern = dateFormats[2];                       // ddMMMyyyy
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        //sdf.setLenient(true);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        ParsePosition p = new ParsePosition(0);
        Date          d = sdf.parse(tstart, p);
        if (d == null) {
            System.out.println("couldn't parse at " + p.getErrorIndex());
            d = new Date(0);
        }
        //System.out.println("start = " + d);
        // set the unit
        sdf.applyPattern("yyyy-MM-dd HH:mm:ss Z");
        setUnit("hours since "
                + sdf.format(d, new StringBuffer(), new FieldPosition(0)));
        // parse the increment
        // vvkk where
        // vv     =       an integer number, 1 or 2 digits
        // kk     =       mn (minute)
        //                hr (hour)
        //                dy (day)
        //                mo (month)
        //                yr (year) 
        String tinc     = levels.get(1).toLowerCase();
        int    incIndex = 0;
        for (int i = 0; i < incStr.length; i++) {
            int index = tinc.indexOf(incStr[i]);
            if (index < 0) {
                continue;
            }
            int numOf = Integer.parseInt(tinc.substring(0, index));
            inc      = numOf;
            incIndex = i;

            break;
        }
        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        calendar.setTime(d);
        vals[0]     = 0;
        initialTime = makeTimeStruct(calendar);
        //System.out.println("initial time = " + initialTime);
        int calInc = calIncs[incIndex];
        double hours =  (double) 1000 * 60 * 60;
        for (int i = 1; i < getSize(); i++) {
            calendar.add(calInc, inc);
            // subtract from origin, convert to hours
            double offset = (calendar.getTime().getTime() - d.getTime()) / hours;  //millis in an hour
            vals[i] = offset;
        }
        return vals;

    }
protected double[] makeLevelValues() {
        List<String> levels = getLevels();
        if (levels == null) {
            return null;
        }
        if (levels.size() != getSize()) {
            // do someting
        }
        // Time is always LINEAR
        int      inc     = 0;
        double[] vals    = new double[getSize()];
        String   tstart  = levels.get(0).trim().toLowerCase();
        String   pattern = null;
        if (tstart.indexOf(":") >= 0) {                     // HH:mmZddMMMyyyy
            pattern = dateFormats[0];
        } else if (tstart.indexOf("z") >= 0) {              // mmZddMMMyyyy
            pattern = dateFormats[1];
        } else if (Character.isLetter(tstart.charAt(0))) {  // MMMyyyy
            pattern = dateFormats[3];
        } else {
            pattern = dateFormats[2];                       // ddMMMyyyy
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        //sdf.setLenient(true);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        ParsePosition p = new ParsePosition(0);
        Date          d = sdf.parse(tstart, p);
        if (d == null) {
            System.out.println("couldn't parse at " + p.getErrorIndex());
            d = new Date(0);
        }
        //System.out.println("start = " + d);
        // set the unit
        sdf.applyPattern("yyyy-MM-dd HH:mm:ss Z");
        setUnit("hours since "
                + sdf.format(d, new StringBuffer(), new FieldPosition(0)));
        // parse the increment
        // vvkk where
        // vv     =       an integer number, 1 or 2 digits
        // kk     =       mn (minute)
        //                hr (hour)
        //                dy (day)
        //                mo (month)
        //                yr (year) 
        String tinc     = levels.get(1).toLowerCase();
        int    incIndex = 0;
        for (int i = 0; i < incStr.length; i++) {
            int index = tinc.indexOf(incStr[i]);
            if (index < 0) {
                continue;
            }
            int numOf = Integer.parseInt(tinc.substring(0, index));
            inc      = numOf;
            incIndex = i;

            break;
        }
        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        calendar.setTime(d);
        vals[0]     = 0;
        initialTime = makeTimeStruct(calendar);
        //System.out.println("initial time = " + initialTime);
        int calInc = calIncs[incIndex];
        double hours =  (double) 1000 * 60 * 60;
        for (int i = 1; i < getSize(); i++) {
            calendar.add(calInc, inc);
            // subtract from origin, convert to hours
            double offset = (calendar.getTime().getTime() - d.getTime()) / hours;  //millis in an hour
            vals[i] = offset;
        }
        return vals;

    }
protected double [ ] makeLevelValues ( ) { List < String > levels = getLevels ( ) ; if ( levels == null ) { return null ; } if ( levels . size ( ) != getSize ( ) ) { // do someting } // Time is always LINEAR int inc = 0 ; double [ ] vals = new double [ getSize ( ) ] ; String tstart = levels . get ( 0 ) . trim ( ) . toLowerCase ( ) ; String pattern = null ; if ( tstart . indexOf ( ":" ) >= 0 ) { // HH:mmZddMMMyyyy pattern = dateFormats [ 0 ] ; } else if ( tstart . indexOf ( "z" ) >= 0 ) { // mmZddMMMyyyy pattern = dateFormats [ 1 ] ; } else if ( Character . isLetter ( tstart . charAt ( 0 ) ) ) { // MMMyyyy pattern = dateFormats [ 3 ] ; } else { pattern = dateFormats [ 2 ] ; // ddMMMyyyy } SimpleDateFormat sdf = new SimpleDateFormat ( pattern ) ; //sdf.setLenient(true); sdf . setTimeZone ( TimeZone . getTimeZone ( "GMT" ) ) ; ParsePosition p = new ParsePosition ( 0 ) ; Date d = sdf . parse ( tstart , p ) ; if ( d == null ) { System . out . println ( "couldn't parse at " + p . getErrorIndex ( ) ) ; d = new Date ( 0 ) ; } //System.out.println("start = " + d); // set the unit sdf . applyPattern ( "yyyy-MM-dd HH:mm:ss Z" ) ; setUnit ( "hours since " + sdf . format ( d , new StringBuffer ( ) , new FieldPosition ( 0 ) ) ) ; // parse the increment // vvkk where // vv     =       an integer number, 1 or 2 digits // kk     =       mn (minute) //                hr (hour) //                dy (day) //                mo (month) //                yr (year)  String tinc = levels . get ( 1 ) . toLowerCase ( ) ; int incIndex = 0 ; for ( int i = 0 ; i < incStr . length ; i ++ ) { int index = tinc . indexOf ( incStr [ i ] ) ; if ( index < 0 ) { continue ; } int numOf = Integer . parseInt ( tinc . substring ( 0 , index ) ) ; inc = numOf ; incIndex = i ; break ; } Calendar calendar = Calendar . getInstance ( TimeZone . getTimeZone ( "GMT" ) ) ; calendar . setTime ( d ) ; vals [ 0 ] = 0 ; initialTime = makeTimeStruct ( calendar ) ; //System.out.println("initial time = " + initialTime); int calInc = calIncs [ incIndex ] ; double hours = ( double ) 1000 * 60 * 60 ; for ( int i = 1 ; i < getSize ( ) ; i ++ ) { calendar . add ( calInc , inc ) ; // subtract from origin, convert to hours double offset = ( calendar . getTime ( ) . getTime ( ) - d . getTime ( ) ) / hours ; //millis in an hour vals [ i ] = offset ; } return vals ; }
Make the level values from the specifications

@return the level values
Make the level values from the specifications