List of usage examples for java.util Date getTime
public long getTime()
From source file:Main.java
public static String getTime(String user_time) { String re_time = null;//from w w w. ja v a 2 s . c om SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date d; try { d = sdf.parse(user_time); long l = d.getTime(); String str = String.valueOf(l); // re_time = str.substring(0, 10); re_time = str; } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return re_time; }
From source file:com.galenframework.ide.jobs.TaskResultsStorageCleanupJob.java
private static long minutesSince(Date date) { Date now = new Date(); if (date != null) { return (now.getTime() - date.getTime()) / 60000L; } else {//from ww w .j av a2s. c o m return now.getTime(); } }
From source file:mitm.common.util.DateTimeUtils.java
public static long diffMilliseconds(Date date1, Date date2) { return date1.getTime() - date2.getTime(); }
From source file:irille.pub.svr.DateUtils.java
/** * Date/* w w w . j a v a2 s . c o m*/ * @param date * @return */ public static Long dateToTimeMillis(Date date) { return date.getTime(); }
From source file:mitm.common.util.DateTimeUtils.java
public static long diffSeconds(Date date1, Date date2) { return (date1.getTime() - date2.getTime()) / DateUtils.MILLIS_PER_SECOND; }
From source file:mitm.common.util.DateTimeUtils.java
public static long diffMinutes(Date date1, Date date2) { return (date1.getTime() - date2.getTime()) / DateUtils.MILLIS_PER_MINUTE; }
From source file:mitm.common.util.DateTimeUtils.java
public static long diffHours(Date date1, Date date2) { return (date1.getTime() - date2.getTime()) / DateUtils.MILLIS_PER_HOUR; }
From source file:mitm.common.util.DateTimeUtils.java
public static long diffDays(Date date1, Date date2) { return (date1.getTime() - date2.getTime()) / DateUtils.MILLIS_PER_DAY; }
From source file:Main.java
/** * Returns Timezone Offset From UTC in format {@code (+|i)HHMM} of specified * Timezone on specified date. If no date is specified, DST is considered * for the current date./*from ww w.ja va 2s . com*/ * * @param tz Timezone * @param date Date or {@code null} * @return Timezone Offset From UTC in format {@code (+|i)HHMM} */ public static String formatTimezoneOffsetFromUTC(TimeZone tz, Date date) { return appendZZZZZ(tz.getOffset(date == null ? System.currentTimeMillis() : date.getTime()), new StringBuilder(5)).toString(); }
From source file:com.kubotaku.android.openweathermap.lib.util.TimeZoneUtil.java
public static TimeZone getTargetTimeZone(LatLng latlng, String apiKey) { TimeZone timeZone = null;/*from ww w .j a v a 2 s. c om*/ try { Date now = new Date(); long currentTime = now.getTime(); String requestURL = String.format(API_URL, latlng.latitude, latlng.longitude, currentTime, apiKey); URL url = new URL(requestURL); InputStream is = url.openConnection().getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); StringBuilder sb = new StringBuilder(); String line; while (null != (line = reader.readLine())) { sb.append(line); } String data = sb.toString(); timeZone = TimeZoneParser.parseTimeZone(data); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return timeZone; }