common_helper/src/main/java/com/xiongyingqi/util/DynamicPassword.java
public byte[] getTimeBytes(int seconds) {
        if (seconds <= 0) {
            throw new IllegalArgumentException("秒数为：" + seconds
                    + "， 指定的密钥更新周期错误！");
        }
        long currentTimeMillis = System.currentTimeMillis();
        // System.out.println(currentTimeMillis);
        // 对秒数取整，比如seconds=30，那么21点00分18秒与21点00分29秒是相同的结果
        currentTimeMillis /= seconds * SECOND;

        // long currentTimeMillisRs = currentTimeMillis * seconds *
        // SECOND;//还原时间位数
        // System.out.println(currentTimeMillisRs);
        // Date date = new Date(currentTimeMillisRs);
        // String dateStr = DateHelper.FORMATTER_LONG.format(date);
        // System.out.println(dateStr);

        return ByteHelper.longToBytes(currentTimeMillis);
    }
public byte[] getTimeBytes(int seconds) {
        if (seconds <= 0) {
            throw new IllegalArgumentException("秒数为：" + seconds
                    + "， 指定的密钥更新周期错误！");
        }
        long currentTimeMillis = System.currentTimeMillis();
        // System.out.println(currentTimeMillis);
        // 对秒数取整，比如seconds=30，那么21点00分18秒与21点00分29秒是相同的结果
        currentTimeMillis /= seconds * SECOND;

        // long currentTimeMillisRs = currentTimeMillis * seconds *
        // SECOND;//还原时间位数
        // System.out.println(currentTimeMillisRs);
        // Date date = new Date(currentTimeMillisRs);
        // String dateStr = DateHelper.FORMATTER_LONG.format(date);
        // System.out.println(dateStr);

        return ByteHelper.longToBytes(currentTimeMillis);
    }
public byte [ ] getTimeBytes ( int seconds ) { if ( seconds <= 0 ) { throw new IllegalArgumentException ( "秒数为：" + secon s + "， 指定的密钥更新周期错误！"); } long currentTimeMillis = System . currentTimeMillis ( ) ; // System.out.println(currentTimeMillis); // 对秒数取整，比如seconds=30，那么21点00分18秒与21点00分29秒是相同的结果 currentTimeMillis /= seconds * SECOND ; // long currentTimeMillisRs = currentTimeMillis * seconds * // SECOND;//还原时间位数 // System.out.println(currentTimeMillisRs); // Date date = new Date(currentTimeMillisRs); // String dateStr = DateHelper.FORMATTER_LONG.format(date); // System.out.println(dateStr); return ByteHelper . longToBytes ( currentTimeMillis ) ; }
根据指定的时间刷新周期获取时间字节
<br>2014-2-11 下午9:13:21

@param seconds
@return
根据指定的时间刷新周期获取时间字节 <br > 2014 - 2 - 11 下午9 : 13 : 21