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:com.insightaction.util.DataLoader.java

public static Timestamp getCurrentTimestamp() {
    Date date = new Date();
    return new Timestamp(date.getTime());
}

From source file:com.whatlookingfor.common.utils.DateUtils.java

/**
 * ?,::.//from   w  ww  .j av  a 2 s. co  m
 *
 * @param date 
 * @return , ::.
 */
public static String formatDateTime(Date date) {
    long timeMillis = date.getTime();
    long day = timeMillis / (24 * 60 * 60 * 1000);
    long hour = (timeMillis / (60 * 60 * 1000) - day * 24);
    long min = ((timeMillis / (60 * 1000)) - day * 24 * 60 - hour * 60);
    long s = (timeMillis / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
    long sss = (timeMillis - day * 24 * 60 * 60 * 1000 - hour * 60 * 60 * 1000 - min * 60 * 1000 - s * 1000);
    return (day > 0 ? day + "," : "") + hour + ":" + min + ":" + s + "." + sss;
}

From source file:org.surfnet.cruncher.message.Aggregator.java

public static String aggregationRecordHash(String idpEntityId, String spEntityId, Date loginDate) {
    String input = dateformat.print(loginDate.getTime()) + "!" + idpEntityId + "!" + spEntityId;
    return DigestUtils.sha1Hex(input);
}

From source file:Main.java

public static JSONObject getLink(String id) throws JSONException {
    Date time = new Date();
    JSONObject obj = new JSONObject();
    obj.put("id", id);
    JSONObject value = new JSONObject();
    value.put("title", "new link");
    value.put("URI", "http://www.foo.com");
    value.put("date", time.getTime());
    JSONArray tags = new JSONArray();
    tags.put("foo");
    value.put("tags", tags);
    obj.put("value", value);
    return obj;/*from w  w  w .ja v  a 2s  .  c o m*/
}

From source file:ibeam.maven.plugins.Tools.java

/**
 * Computation of the elapsed days between two dates.
 * /*from w w  w .  ja  v  a2  s  .co m*/
 * @param date1
 * @param date2
 * @return the number of days between two given date
 */
public static int compareDaysBetweenDates(final Date date1, final Date date2) {
    return (int) ((date2.getTime() - date1.getTime()) / (1000 * 60 * 60 * 24));
}

From source file:net.firejack.platform.core.utils.DateUtils.java

/**
 * Converts the date into the number of days since the epoch
 * @param date - date to be converted/*  w w w  .  j  a  va2 s .  c  o m*/
 * @return number of days since the epoch
 */
public static int date2EpochDays(Date date) {
    long millis = date.getTime();
    return (int) (millis / 86400000);
}

From source file:Main.java

public static long parseTimeStamp(String timeStamp) throws ParseException {
    SimpleDateFormat format = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
    Date date;
    try {/*from   ww w . j  av a2s .c o m*/
        date = format.parse(timeStamp);
    } catch (ParseException e) {
        SimpleDateFormat optFormat = new SimpleDateFormat("yy-MM-dd HH:mm");
        date = optFormat.parse(timeStamp);
    }
    return date.getTime();
}

From source file:Main.java

public static String getLocalTimeFromUTC(String UTCTime) {
    java.util.Date UTCDate = null;
    String localTimeStr = null;//from   w  w  w .j  av  a 2s.c  o  m
    SimpleDateFormat format = new SimpleDateFormat("HH:mm", Locale.getDefault());
    try {
        UTCDate = format.parse(UTCTime);
        localTimeStr = format.format(UTCDate.getTime() + TimeZone.getDefault().getRawOffset());
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return localTimeStr;
}

From source file:ua.com.fielden.platform.example.swing.booking.BookingChartPanelExample.java

private static Marker createNowMarker(final Date now) {
    final ValueMarker valuemarker = new ValueMarker(now.getTime());
    valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
    valuemarker.setPaint(Color.BLACK);
    valuemarker.setLabel("Today");
    valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    valuemarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    return valuemarker;
}

From source file:edu.ucsb.cs.hybrid.HybridDriver.java

public static void run(JobConf job) throws IOException {
    String ret = stars() + "\n  Running job:  " + job.getJobName() + "\n  Input Path:   {";
    Path inputs[] = FileInputFormat.getInputPaths(job);
    for (int ctr = 0; ctr < inputs.length; ctr++) {
        if (ctr > 0) {
            ret += "\n                ";
        }/*from  w  w w.ja  va  2s .  c  o  m*/
        ret += inputs[ctr].toString();
    }
    ret += "}\n";
    ret += "  Output Path:  " + FileOutputFormat.getOutputPath(job) + "\n";
    ret += "  Threshold:    " + job.getFloat(Config.THRESHOLD_PROPERTY, Config.THRESHOLD_VALUE) + "\n";
    System.err.println(ret);

    Date startTime = new Date();
    JobClient.runJob(job);
    Date end_time = new Date();
    System.err.println(
            "Similarity job took " + (end_time.getTime() - startTime.getTime()) / (float) 1000.0 + " seconds.");
}