Example usage for java.util Date getTime

List of usage examples for java.util Date getTime

Introduction

In this page you can find the example usage for java.util Date getTime.

Prototype

public long getTime() 

Source Link

Document

Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.

Usage

From source file:de.mpg.escidoc.services.tools.scripts.person_grants.Util.java

/**
 * get a admin user handle for an escidoc instance
 * /* w  w w.  j  a  v  a  2  s.  c  o m*/
 * @param adminUserName
 * @param adminUserPassword
 * @param frameworkUrl
 * @return
 */
public static String getAdminUserHandle(String adminUserName, String adminUserPassword, String frameworkUrl) {
    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(adminUserName, adminUserPassword, frameworkUrl);
        } catch (Exception e) {
            System.out.println("Exception logging on admin user.");
            e.printStackTrace();
        }
    }
    return adminUserHandle;
}

From source file:com.espertech.esper.client.util.DateTime.java

private static Calendar parseGetCal(String str, SimpleDateFormat format) {
    Date d = parse(str, format);
    if (d == null) {
        return null;
    }//from   w w  w.  j  a  v  a2 s  . c o m
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(d.getTime());
    return cal;
}

From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java

public static LocalDateTime getLocalDateTime(Date date) {
    Instant instant = Instant.ofEpochMilli(date.getTime());
    return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
}

From source file:com.projity.util.DateTime.java

public static long fromGmt(long d) {
    if (d == 0)//from   w w w.j av a2s  .  c o m
        return 0;
    Date date = new Date(d);
    return new Date(date.getTime() + (isGmtConvertion() ? 60000L * date.getTimezoneOffset() : 0)).getTime();

}

From source file:Main.java

/**
 * Gets the XML Gregorian calendar from date.
 *
 * @param date the date./*from w  ww  .j av a2s .  co  m*/
 *
 * @return the XML Gregorian calendar.
 */
public static XMLGregorianCalendar getXMLDate(Date date) {
    DatatypeFactory dataTypeFactory;
    try {
        dataTypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException e) {
        throw new RuntimeException(e);
    }
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTimeInMillis(date.getTime());
    return dataTypeFactory.newXMLGregorianCalendar(gc);
}

From source file:com.jredrain.tag.CronTag.java

public static String diffdate(Date date1, Date date2) {
    if (date1 == null || date2 == null)
        return "0";
    long durationMillisecond = Math.abs(date1.getTime() - date2.getTime());
    long day = durationMillisecond / (24 * 60 * 60 * 1000);
    long hour = (durationMillisecond / (60 * 60 * 1000) - day * 24);
    long min = ((durationMillisecond / (60 * 1000)) - day * 24 * 60 - hour * 60);
    long second = (durationMillisecond / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
    StringBuilder ret = new StringBuilder();
    if (day > 0L) {
        ret.append(day).append("");
    }/*from   w  w  w.  j av a  2 s . com*/
    if (hour > 0L) {
        ret.append(hour).append("");
    }
    if (min > 0L) {
        ret.append(min).append("");
    }
    if (second > 0L) {
        ret.append(second).append("");
    }
    if (ret.toString().equals("")) {
        ret.append("<1");
    }
    return ret.toString();
}

From source file:org.hydroponics.dao.JDBCHydroponicsDaoImpl.java

private static int daysBetween(Date d1, Date d2) {
    return (int) ((d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24));
}

From source file:biospectra.BioSpectra.java

private static void index(CommandArgumentIndex arg) throws Exception {
    Configuration conf = null;/*w ww  .ja va 2s .  co m*/

    if (arg.getJsonConfiguration() != null && !arg.getJsonConfiguration().isEmpty()) {
        conf = Configuration.createInstance(new File(arg.getJsonConfiguration()));
    } else {
        conf = new Configuration();
        conf.setIndexPath(arg.getIndexDir());
    }

    Indexer indexer = new Indexer(conf);

    List<File> refereneFiles = FastaFileHelper.findFastaDocs(arg.getReferenceDir());
    for (File fastaDoc : refereneFiles) {
        LOG.info("indexing " + fastaDoc.getAbsolutePath() + " started");
        Date start = new Date();

        indexer.index(fastaDoc);

        Date end = new Date();
        LOG.info("indexing " + fastaDoc.getAbsolutePath() + " finished - " + (end.getTime() - start.getTime())
                + " milliseconds");
    }

    indexer.close();
}

From source file:net.kamhon.ieagle.util.DateUtil.java

/**
 * //from   w  w  w  . j ava  2 s . c om
 * @param date
 * @param with
 * @return date - with
 */
public static int getDiffHoursInInteger(Date date, Date with) {
    long dateInLong = date.getTime();
    long withInLong = with.getTime();
    return (int) ((dateInLong - withInLong) / (60 * 60 * 1000));
}