List of usage examples for java.util Date getTime
public long getTime()
From source file:edu.mum.service.impl.EventServiceImpl.java
private static Date addMinutesToDate(int minutes, Date beforeTime) { final long ONE_MINUTE_IN_MILLIS = 60000;//millisecs long curTimeInMs = beforeTime.getTime(); Date afterAddingMins = new Date(curTimeInMs + (minutes * ONE_MINUTE_IN_MILLIS)); return afterAddingMins; }
From source file:com.oncecorp.visa3d.bridge.utility.JdbcUtils.java
/** * This method extracts string represented date value into <tt>long</tt> * type value./* w w w.ja v a2 s .com*/ * @param dateString The string represents the date. * @param dateFormat The format pattern string. The format syntax see the * API document of java.text.SimpleDateFormat. * @return The <tt>long</tt> type value. */ public static long extractDateValue(String dateString, String dateFormat) { SimpleDateFormat format = new SimpleDateFormat(dateFormat); try { Date date = format.parse(dateString); return date.getTime(); } catch (Exception e) { return -1L; } }
From source file:Main.java
public static String getLeftDay(String date) { if ("".equals(date) || date == null) { return ""; }/* www . j a v a 2 s.c o m*/ Date cur = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd", getLocale()); String curTime = sdf.format(cur); Date dt = new Date(); long day = 0; try { dt = sdf.parse(curTime); long l = Long.parseLong(date) - dt.getTime(); if (l > 0) { day = l / (24 * 60 * 60 * 1000); } else { day = 0; } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NumberFormatException e) { e.printStackTrace(); } return Long.toString(day); }
From source file:Main.java
@Deprecated // Deprecated because this uses org.apache.http, which is itself deprecated public static HttpCookie servletCookieFromApacheCookie(org.apache.http.cookie.Cookie apacheCookie) { if (apacheCookie == null) { return null; }//from w w w . ja v a2 s . co m String name = apacheCookie.getName(); String value = apacheCookie.getValue(); HttpCookie cookie = new HttpCookie(name, value); value = apacheCookie.getDomain(); if (value != null) { cookie.setDomain(value); } value = apacheCookie.getPath(); if (value != null) { cookie.setPath(value); } cookie.setSecure(apacheCookie.isSecure()); value = apacheCookie.getComment(); if (value != null) { cookie.setComment(value); } // version cookie.setVersion(apacheCookie.getVersion()); // From the Apache source code, maxAge is converted to expiry date using the following formula // if (maxAge >= 0) { // setExpiryDate(new Date(System.currentTimeMillis() + maxAge * 1000L)); // } // Reverse this to get the actual max age Date expiryDate = apacheCookie.getExpiryDate(); if (expiryDate != null) { long maxAge = (expiryDate.getTime() - System.currentTimeMillis()) / 1000; // we have to lower down, no other option cookie.setMaxAge((int) maxAge); } // return the servlet cookie return cookie; }
From source file:com.baifendian.swordfish.common.utils.DateUtils.java
/** * ?//from w ww . j ava2 s. c o m * * @param future * @param old * @return */ public static boolean compare(Date future, Date old) { return future.getTime() > old.getTime(); }
From source file:edu.usu.sdl.openstorefront.common.util.TimeUtil.java
/** * Get the end of the day passed in// w w w .j a va 2 s . com * * @param date * @return end of the day or null if date was null */ public static Date endOfDay(Date date) { if (date != null) { Instant instant = Instant.ofEpochMilli(date.getTime()); LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault()); localDateTime = localDateTime.withHour(23).withMinute(59).withSecond(59) .with(ChronoField.MILLI_OF_SECOND, 999); return new Date(localDateTime.toInstant(ZoneOffset.UTC).toEpochMilli()); } return date; }
From source file:gov.nih.nci.caintegrator.common.DateUtil.java
/** * Returns the difference between two times in Minutes apart. * @param date1 first date.//from w ww. j a va 2 s . c o m * @param date2 second date. * @return difference between the dates. */ public static Long compareDatesInMinutes(Date date1, Date date2) { return Math.abs(date1.getTime() - date2.getTime()) / MILLISECONDS_PER_SECOND / SECONDS_PER_MINUTE; }
From source file:Main.java
public static void setBreathingBackgroundColor(final View view, final int color) { Date firstDate = new Date(); final long firstTime = firstDate.getTime(); mAsyncTask = new AsyncTask<Void, Integer, Void>() { int n = 1, t = 3000; boolean increaseN; @Override// ww w . j ava 2 s. co m protected Void doInBackground(Void... params) { while (!isCancelled() || !mCancelled) { Date currentDate = new Date(); long diffTime = currentDate.getTime() - firstTime; if (diffTime > n * t) { increaseN = true; } if (increaseN) { n++; increaseN = false; } double y = getBreathingY(diffTime, n, t); int alpha = (int) ((y * 0.618f + 0.382f) * 255); int resultColor = setAlphaComponent(color, alpha); mColor = resultColor; publishProgress(resultColor); try { Thread.sleep(38); } catch (InterruptedException e) { e.printStackTrace(); } } return null; } @Override protected void onProgressUpdate(Integer... values) { super.onProgressUpdate(values); view.setBackgroundColor(values[0]); } }; executeAsyncTask(mAsyncTask); }
From source file:fr.insalyon.creatis.vip.query.server.rpc.FileDownload.java
private static java.sql.Timestamp getCurrentTimeStamp() { java.util.Date today = new java.util.Date(); return new java.sql.Timestamp(today.getTime()); }
From source file:irille.pub.svr.DateUtils.java
/** * /* w w w.ja v a 2s .c om*/ * * @param d1 * @param d2 * @return */ public static int diff_in_date(Date d1, Date d2) { return (int) Math.abs(((d1.getTime() - d2.getTime()) / 86400000)); }