package com.ifish.jpush.utils; import java.text.ParseException; import java.text.SimpleDateFormat; public class TimeUtils { private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; private static final String TIME_ONLY_FORMAT = "HH:mm:ss"; public static boolean isDateFormat(String time) { try { SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT); format.setLenient(false); format.parse(time); } catch (ParseException e) { return false; } return true; } public static boolean isTimeFormat(String time) { try{ SimpleDateFormat format = new SimpleDateFormat(TIME_ONLY_FORMAT); format.setLenient(false); format.parse(time); } catch (ParseException e) { return false; } return true; } }