package com.atlassian.stash.internal.util;

import java.util.Date;

public class TimestampUtils {

    /**
     * Wherever {@link Date}s have been persisted in MySQL or Microsoft SQL Server DATETIME or TIMESTAMP columns, they
     * may lose subsecond precision.  See {@link HibernateClusteredJobDaoTest#assertEquals(Date, Date)} for example.
     */
    public static boolean equalToSecondPrecision(Date a, Date b) {
        return a == b || a != null && b != null && Math.abs(a.getTime() - b.getTime()) <= 1000L;
    }

}
