Timestamp, java.util.Date的转换以及比较

    private static String validateNoteActivatedDate(DynamicEntity entity,
            String activationDateCNDN){
        Timestamp timestamp = null;
        Object tempObject = entity.get("createDate");
        if (tempObject == null){
            timestamp = new Timestamp(System.currentTimeMillis());
        }else{
            timestamp = new Timestamp(((Date) tempObject).getTime());
        }
        if (timestamp != null && activationDateCNDN != null) {
            SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
            Date activatedDate;
            try {
                activatedDate = df.parse(activationDateCNDN);
            } catch (ParseException e) {
                return VALMSG_stringParseDateError;
            }
            Date createDate = new Date(timestamp.getTime());

            if (createDate.before(activatedDate) && entity.get("offsetNoteId") != null) {
                return VALMSG_activatedDateError;
            }
        }
        return null;
    }
 

你可能感兴趣的:(Timestamp, java.util.Date的转换以及比较)