static public Date getStandardDate ( String text ) { double value ; String udunitString ; text = text . trim ( ) ; StringTokenizer stoker = new StringTokenizer ( text ) ; String firstToke = stoker . nextToken ( ) ; try { value = Double . parseDouble ( firstToke ) ; udunitString = text . substring ( firstToke . length ( ) ) ; } catch ( NumberFormatException e ) { // stupid way to test if it starts with a number value = 0.0 ; udunitString = text ; } DateUnit du ; try { du = new DateUnit ( udunitString ) ; } catch ( Exception e ) { return null ; } return du . makeDate ( value ) ; }
Create a java . util . Date from this udunits String .