List of usage examples for java.util Date getTime
public long getTime()
From source file:com.bc.fiduceo.TestUtil.java
public static void assertWithinLastMinute(Date expected, Date actual) { final long timeDeltaInMillis = Math.abs(expected.getTime() - actual.getTime()); assertTrue(timeDeltaInMillis < 60000); }
From source file:com.projity.util.DateTime.java
public static Date dayFloor(Date date) { return new Date(dayFloor(date.getTime())); }
From source file:de.mpg.escidoc.services.framework.AdminHelper.java
/** * Gets the admin users user handle./* ww w . j av a2 s .c om*/ * * @return The admin's user handle. */ public static String getAdminUserHandle() { Date now = new Date(); // Renew every hour if (adminUserHandle == null || loginTime == null || loginTime.getTime() < now.getTime() - 1 * 60 * 60 * 1000) { try { loginTime = new Date(); adminUserHandle = loginUser(PropertyReader.getProperty("framework.admin.username"), PropertyReader.getProperty("framework.admin.password")); } catch (Exception e) { LOGGER.error("Exception logging on admin user.", e); } } return adminUserHandle; }
From source file:com.coinblesk.server.utilTest.ServerCalls.java
public static SignTO signServerCallInput(List<Pair<byte[], Long>> outpointCoinPair, Address to, long amount, ECKey client, Date date) throws Exception { SignTO prepareHalfSignTO = new SignTO().outpointsCoinPair(outpointCoinPair).amountToSpend(amount) .p2shAddressTo(to.toString()).publicKey(client.getPubKey()).currentDate(date.getTime()); SerializeUtils.signJSON(prepareHalfSignTO, client); return prepareHalfSignTO; }
From source file:axiom.util.Logger.java
static synchronized void renderDate() { Date date = new Date(); dateCache = dformat.format(date);/* w ww .j av a 2 s.c o m*/ dateLastRendered = date.getTime(); }
From source file:com.dianxin.imessage.common.util.DateUtil.java
/** * ?: yyyy-MM-dd// ww w .j av a 2 s .c o m * * @param start * @param end * @return * @throws Exception */ public static int getDayDiff(String start, String end) throws Exception { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); try { Date startTime = df.parse(start); Date endTime = df.parse(end); long interval = endTime.getTime() - startTime.getTime(); if (interval < 0) { throw new Exception(" start > end"); } int day = (int) (interval / (24 * 60 * 60 * 1000)); return day; } catch (ParseException e) { throw new Exception("? yyyy-MM-dd"); } }
From source file:com.dianxin.imessage.common.util.DateUtil.java
/** * ?: yyyy-MM-dd HH:mm:ss//from w w w . j a v a2 s.c o m * * @param start * @param end * @return * @throws Exception */ public static int getSecondsDiff(String start, String end) throws Exception { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date startTime = df.parse(start); Date endTime = df.parse(end); long interval = endTime.getTime() - startTime.getTime(); if (interval < 0) { throw new Exception(" start > end"); } int minute = (int) (interval / (1000)); return minute; } catch (ParseException e) { throw new Exception("? yyyy-MM-dd HH:mm:ss"); } }
From source file:com.dianxin.imessage.common.util.DateUtil.java
/** * ?: yyyy-MM-dd HH:mm:ss//from www . j a va 2 s . co m * * @param start * @param end * @return * @throws Exception */ public static int getMinuteDiff(String start, String end) throws Exception { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { Date startTime = df.parse(start); Date endTime = df.parse(end); long interval = endTime.getTime() - startTime.getTime(); if (interval < 0) { throw new Exception(" start > end"); } int minute = (int) (interval / (60 * 1000)); return minute; } catch (ParseException e) { throw new Exception("? yyyy-MM-dd HH:mm:ss"); } }
From source file:eu.eubrazilcc.lvl.storage.security.shiro.CryptProvider.java
/** * Joins the tokens and dates provided as parameters with a salt generated from {@link #DEFAULT_STRENGTH} random bytes and computes a digest using * the PBKDF2 key derivation function./*from ww w . j a v a 2s . com*/ * @param tokens - list of input tokens * @param dates - list of input dates * @return a digest of the input parameters (tokens and dates). * @throws IOException is thrown if the computation of the digest fails. * @see <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html">JCA Standard Algorithm Name Documentation</a> */ private static byte[] digest(final @Nullable String[] tokens, @Nullable final Date[] dates) throws IOException { try { String mixName = ""; if (tokens != null) { for (final String token : tokens) { mixName += (token != null ? token.trim() : ""); } } if (dates != null) { for (final Date date : dates) { mixName += (date != null ? Long.toString(date.getTime()) : ""); } } // compute digest final byte[] bytesOfMixName = mixName.getBytes(UTF_8.name()); final char[] charOfMixName = new String(bytesOfMixName).toCharArray(); final byte[] salt = generateSalt(SALT_BYTES_SIZE); final SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); final PBEKeySpec spec = new PBEKeySpec(charOfMixName, salt, KEY_DEVIATION_ITERATIONS, SALT_BYTES_SIZE * 8); return factory.generateSecret(spec).getEncoded(); } catch (Exception e) { throw new IOException("Digest computation has failed", e); } }
From source file:org.cretz.sbnstat.gource.Gourcer.java
private static String getGourceLine(Date timestamp, String username, char type, String title, String color) { StringBuilder builder = new StringBuilder().append(timestamp.getTime() / 1000).append('|').append(username) .append('|').append(type).append('|').append(title.replace('|', '-')); if (color != null) { builder.append('|'); builder.append(color);/*from w w w .j a va2 s . c o m*/ } return builder.toString(); }