class HMSDebuggerComponent {

    public Date parseDateFromFileName( String logArchiveName )
        throws HmsException
    {
        if ( isParameterNotNullNonEmpty( logArchiveName ) && logArchiveName.matches( HMS_ARCHIVE_REGEX ) )
        {
            // The string has been checked with regex expression, so it is safe to use substring.
            // String fileTimeStamp = logArchiveName.substring(logArchiveName.length()-23, logArchiveName.length()-4);

            String fileTimeStamp = null;
            Pattern p = Pattern.compile( HMS_TIMESTAMP_EXTRACTION_REGEX );
            Matcher m = p.matcher( logArchiveName );
            if ( m.find() )
            {
                logger.debug( "Extracted timestamp for log archive [ " + logArchiveName + " ] is [ " + m.group( 1 )
                    + " ]" );
                fileTimeStamp = m.group( 1 );
            }

            DateFormat df = new SimpleDateFormat( TIMESTAMP_FORMAT );
            Date parsedDate;
            try
            {
                parsedDate = df.parse( fileTimeStamp );
                logger.debug( "Parsed date :" + parsedDate );
                return parsedDate;
            }
            catch ( ParseException e )
            {
                String err = "Unable to parse date from the filename [ " + logArchiveName + " ]";
                logger.error( err );
                throw new HmsException( err, e );
            }
        }
        else
        {
            String err = "Cannot get Date from log Archive name [ " + logArchiveName
                + " ], because either it is null or empty. or it doesnot matches the regular expression [ "
                + HMS_ARCHIVE_REGEX + " ]";
            logger.error( err );
            throw new HmsException( err );
        }
    }

}