Here you can find the source of isDurationFormatPattern(String formatPattern)
Parameter | Description |
---|---|
formatPattern | pattern |
public static boolean isDurationFormatPattern(String formatPattern)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.List; public class Main { /**// w w w.j a va2 s .com * Characters accepted in duration format pattern. */ public static final List<String> ACCEPTED_CHAR_DURATION_PATTERN = Arrays.asList("dd", "hh", "mm", "ss"); /** * Determine if the duration format pattern is valid. * * @param formatPattern * pattern * @return true --> valid, otherwise false */ public static boolean isDurationFormatPattern(String formatPattern) { if (formatPattern == null) { return false; } final int length = formatPattern.length(); if (length < 2) { return false; } formatPattern = formatPattern.toLowerCase(); final String first = formatPattern.substring(0, 2); final String last = formatPattern.substring(length - 2); if (ACCEPTED_CHAR_DURATION_PATTERN.contains(first) && ACCEPTED_CHAR_DURATION_PATTERN.contains(last)) { return true; } return false; } }