cdm/src/main/java/ucar/nc2/time/CalendarPeriod.java
public static CalendarPeriod.Field fromUnitString(String udunit) {
    udunit = udunit.trim();
    udunit = udunit.toLowerCase();

    if (udunit.equals("s")) return Field.Second;
    if (udunit.equals("ms")) return Field.Millisec;

      // eliminate plurals
    if (udunit.endsWith("s")) udunit = udunit.substring(0, udunit.length()-1);

    switch (udunit) {
      case "second":
      case "sec":
        return Field.Second;
      case "millisecond":
      case "millisec":
      case "msec":
        return Field.Millisec;
      case "minute":
      case "min":
        return Field.Minute;
      case "hour":
      case "hr":
      case "h":
        return Field.Hour;
      case "day":
      case "d":
        return Field.Day;
      case "month":
      case "mon":
        return Field.Month;
      case "year":
      case "yr":
        return Field.Year;
      default:
        throw new IllegalArgumentException("cant convert " + udunit + " to CalendarPeriod");
    }
  }
public static CalendarPeriod.Field fromUnitString(String udunit) {
    udunit = udunit.trim();
    udunit = udunit.toLowerCase();

    if (udunit.equals("s")) return Field.Second;
    if (udunit.equals("ms")) return Field.Millisec;

      // eliminate plurals
    if (udunit.endsWith("s")) udunit = udunit.substring(0, udunit.length()-1);

    switch (udunit) {
      case "second":
      case "sec":
        return Field.Second;
      case "millisecond":
      case "millisec":
      case "msec":
        return Field.Millisec;
      case "minute":
      case "min":
        return Field.Minute;
      case "hour":
      case "hr":
      case "h":
        return Field.Hour;
      case "day":
      case "d":
        return Field.Day;
      case "month":
      case "mon":
        return Field.Month;
      case "year":
      case "yr":
        return Field.Year;
      default:
        throw new IllegalArgumentException("cant convert " + udunit + " to CalendarPeriod");
    }
  }
public static CalendarPeriod . Field fromUnitString ( String udunit ) { udunit = udunit . trim ( ) ; udunit = udunit . toLowerCase ( ) ; if ( udunit . equals ( "s" ) ) return Field . Second ; if ( udunit . equals ( "ms" ) ) return Field . Millisec ; // eliminate plurals
 if ( udunit . endsWith ( "s" ) ) udunit = udunit . substring ( 0 , udunit . length ( ) - 1 ) ; switch ( udunit ) { case "second" : case "sec" : return Field . Second ; case "millisecond" : case "millisec" : case "msec" : return Field . Millisec ; case "minute" : case "min" : return Field . Minute ; case "hour" : case "hr" : case "h" : return Field . Hour ; case "day" : case "d" : return Field . Day ; case "month" : case "mon" : return Field . Month ; case "year" : case "yr" : return Field . Year ; default : throw new IllegalArgumentException ( "cant convert " + udunit + " to CalendarPeriod" ) ; } }
Convert a period string into a CalendarPeriod.Field.
@param udunit period string
@return CalendarPeriod.Field enum
@throws IllegalArgumentException if not valid format
Convert a period string into a CalendarPeriod . Field .