Example usage for java.util Date setTime

List of usage examples for java.util Date setTime

Introduction

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

Prototype

public void setTime(long time) 

Source Link

Document

Sets this Date object to represent a point in time that is time milliseconds after January 1, 1970 00:00:00 GMT.

Usage

From source file:io.github.runassudo.ptoffline.utils.TransportrUtils.java

static public void setArrivalTimes(Context context, TextView timeView, TextView delayView, Stop stop) {
    if (stop.getArrivalTime() == null)
        return;/*ww w . j  a  va  2  s.  co  m*/

    Date time = new Date(stop.getArrivalTime().getTime());

    if (stop.isArrivalTimePredicted() && stop.getArrivalDelay() != null) {
        long delay = stop.getArrivalDelay();
        time.setTime(time.getTime() - delay);
        delayView.setText(getDelayText(delay));
    }
    timeView.setText(DateUtils.getTime(context, time));
}

From source file:io.github.runassudo.ptoffline.utils.TransportrUtils.java

static public void setDepartureTimes(Context context, TextView timeView, TextView delayView, Stop stop) {
    if (stop.getDepartureTime() == null)
        return;/*  w  ww.j  a  v a  2  s. com*/

    Date time = new Date(stop.getDepartureTime().getTime());

    if (stop.isDepartureTimePredicted() && stop.getDepartureDelay() != null) {
        long delay = stop.getDepartureDelay();
        time.setTime(time.getTime() - delay);
        delayView.setText(getDelayText(delay));
    }
    timeView.setText(DateUtils.getTime(context, time));
}

From source file:de.grobox.liberario.utils.TransportrUtils.java

static public void setArrivalTimes(Context context, TextView timeView, TextView delayView, Stop stop) {
    if (stop.getArrivalTime() == null)
        return;/* w  w w  . jav a2 s  .c  om*/

    Date time = new Date(stop.getArrivalTime().getTime());

    if (stop.isArrivalTimePredicted() && stop.getArrivalDelay() != null) {
        long delay = stop.getArrivalDelay();
        time.setTime(time.getTime() - delay);
        delayView.setText(DateUtils.getDelayText(delay));
    }
    timeView.setText(DateUtils.getTime(context, time));
}

From source file:de.grobox.liberario.utils.TransportrUtils.java

static public void setDepartureTimes(Context context, TextView timeView, TextView delayView, Stop stop) {
    if (stop.getDepartureTime() == null)
        return;/* w ww  .ja  va2  s  .  co  m*/

    Date time = new Date(stop.getDepartureTime().getTime());

    if (stop.isDepartureTimePredicted() && stop.getDepartureDelay() != null) {
        long delay = stop.getDepartureDelay();
        time.setTime(time.getTime() - delay);
        delayView.setText(DateUtils.getDelayText(delay));
    }
    timeView.setText(DateUtils.getTime(context, time));
}

From source file:com.opendesign.utils.Day.java

public static Date getCurrentDate() {

    Date date = Calendar.getInstance().getTime();
    date.setTime(System.currentTimeMillis());

    return date;//from  w  ww .ja  v a 2  s.  c  om
}

From source file:fr.mael.microrss.service.impl.ParseTrigger.java

@Override
public Date nextExecutionTime(TriggerContext triggerContext) {
    Date lastDate = triggerContext.lastCompletionTime();
    if (lastDate == null) {
        lastDate = new Date();
    }//from w ww . j  a va2 s.c  o m
    Date newDate = new Date();
    newDate.setTime(lastDate.getTime() + EXECUTION_INTERVAL);
    return newDate;
}

From source file:ro.agrade.jira.qanda.issuepanel.UIFormatter.java

/**
 * Formats the TS//from  ww w  .java 2s.c  o  m
 * @param ts the timestamp
 * @return the formatted TS, as a string
 */
@HtmlSafe
public String formatTimeStamp(long ts) {
    Date d = new Date();
    d.setTime(ts);
    DateFormat fmt = new SimpleDateFormat(STDFORMAT, authContext.getLocale());
    return fmt.format(d);
}

From source file:fedroot.dacs.http.DacsCookie.java

public DacsCookie(String domain, String name, String value, boolean secure) throws DacsRuntimeException {
    super(name, value);

    if (!isDacsCookieName(name)) {
        throw new DacsRuntimeException("invalid DACS cookie: " + name);
    }//w  w  w .  ja v  a 2 s .co  m

    setVersion(0);
    if (domain.startsWith(".")) {
        setDomain(domain);
    } else {
        setDomain("." + domain);
    }
    setPath("/");

    // TODO: set expire date from DACS configuration
    Date expires = new Date();
    expires.setTime(expires.getTime() + 3600);
    setExpiryDate(expires);

    setSecure(secure);
}

From source file:com.adaptris.core.fs.LastModifiedFilter.java

protected Date filterDate() throws Exception {
    Date filterDate = new Date();
    if (NumberUtils.isDigits(when)) {
        filterDate.setTime(Long.parseLong(when));
    } else {//from w  w w  .  j a  v  a2s  . c om
        Duration duration = DatatypeFactory.newInstance().newDuration(when);
        duration.addTo(filterDate);
    }
    return filterDate;
}

From source file:no.opentech.shoppinglist.file.JSONHandler.java

public ArrayList<Item> createItemListFromJSON(String json) {
    ArrayList<Item> itemList = new ArrayList<Item>();
    JSONArray jsonItems;/*from www . j  av  a2  s. c o  m*/
    try {
        jsonItems = new JSONArray(json);
        if ((jsonItems.length() % 6) != 0)
            return null;
        for (int i = 0; i < jsonItems.length(); i += 6) {
            Item item = new Item();
            item.setName(jsonItems.getString(i));
            item.setDescription(jsonItems.getString(i + 1));
            item.setUsageCounter(jsonItems.getInt(i + 2));
            item.setAvgNumberInLine(jsonItems.getInt(i + 3));
            Date first = new Date();
            first.setTime(jsonItems.getLong(i + 4));
            Date last = new Date();
            last.setTime(jsonItems.getLong(i + 5));
            item.setFirstSeen(first);
            item.setLastSeen(last);
            itemList.add(item);
        }
    } catch (JSONException e) {
        return null;
    }
    return itemList;
}