Java examples for java.util:Date Format
check Date YYMM format
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String expireDate = "java2s.com"; System.out.println(checkDateYYMM(expireDate)); }/*from ww w.j av a2 s . com*/ public static boolean checkDateYYMM(String expireDate) { if (expireDate != null && expireDate.length() == 4) { int month = Integer.parseInt(expireDate.substring(2)); if (month >= 1 && month <= 12) { return true; } else { return false; } } else { return false; } } }