cdm/src/main/java/ucar/nc2/units/TimeDuration.java
static public TimeDuration parseW3CDuration(String text) throws java.text.ParseException {
    TimeDuration td = new TimeDuration();

    text = (text == null) ? "" : text.trim();
    td.text = text;

    try {
      DatatypeFactory factory = DatatypeFactory.newInstance();
      Duration d = factory.newDuration(text);
      //long secs = d.getTimeInMillis(new Date()) / 1000;
      
      Calendar c  = Calendar.getInstance();
      c.set(1900, 0, 1, 0, 0, 0);
      long secs =d.getTimeInMillis( c.getTime() ) / 1000;      
      
      td.timeUnit = new TimeUnit(secs + " secs");
    } catch (Exception e) {
      throw new java.text.ParseException(e.getMessage(), 0);
    }
    return td;
  }
static public TimeDuration parseW3CDuration(String text) throws java.text.ParseException {
    TimeDuration td = new TimeDuration();

    text = (text == null) ? "" : text.trim();
    td.text = text;

    try {
      DatatypeFactory factory = DatatypeFactory.newInstance();
      Duration d = factory.newDuration(text);
      //long secs = d.getTimeInMillis(new Date()) / 1000;
      
      Calendar c  = Calendar.getInstance();
      c.set(1900, 0, 1, 0, 0, 0);
      long secs =d.getTimeInMillis( c.getTime() ) / 1000;      
      
      td.timeUnit = new TimeUnit(secs + " secs");
    } catch (Exception e) {
      throw new java.text.ParseException(e.getMessage(), 0);
    }
    return td;
  }
static public TimeDuration parseW3CDuration ( String text ) throws java . text . ParseException { TimeDuration td = new TimeDuration ( ) ; text = ( text == null ) ? "" : text . trim ( ) ; td . text = text ; try { DatatypeFactory factory = DatatypeFactory . newInstance ( ) ; Duration d = factory . newDuration ( text ) ; //long secs = d.getTimeInMillis(new Date()) / 1000; Calendar c = Calendar . getInstance ( ) ; c . set ( 1900 , 0 , 1 , 0 , 0 , 0 ) ; long secs = d . getTimeInMillis ( c . getTime ( ) ) / 1000 ; td . timeUnit = new TimeUnit ( secs + " secs" ) ; } catch ( Exception e ) { throw new java . text . ParseException ( e . getMessage ( ) , 0 ) ; } return td ; }
A time span as defined in the W3C XML Schema 1.0 specification:
"PnYnMnDTnHnMnS, where nY represents the number of years, nM the number of months, nD the number of days,
'T' is the date/time separator, nH the number of hours, nM the number of minutes and nS the number of seconds.
The number of seconds can include decimal digits to arbitrary precision."

@param text parse this text, format PnYnMnDTnHnMnS
@return TimeDuration
@throws java.text.ParseException when text is misformed
A time span as defined in the W3C XML Schema 1 . 0 specification : PnYnMnDTnHnMnS where nY represents the number of years nM the number of months nD the number of days T is the date / time separator nH the number of hours nM the number of minutes and nS the number of seconds . The number of seconds can include decimal digits to arbitrary precision .