List of usage examples for java.util Date getTime
public long getTime()
From source file:pt.lsts.neptus.util.bathymetry.TidCachedData.java
public static void test(String[] args) throws Exception { TidReader.main(args);// w ww . j a v a2s . com JFreeChart timeSeriesChart = null; TimeSeriesCollection tsc = new TimeSeriesCollection(); ValueMarker marker = new ValueMarker(System.currentTimeMillis()); ValueMarker levelMarker = new ValueMarker(0); String tmpFolder = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator", "/"); File tidFx = new File(tmpFolder + "tmp.tid"); TidCachedData tide = new TidCachedData(tidFx); TimeSeries ts = new TimeSeries(I18n.text("Tide level")); tsc.addSeries(ts); Date sDate = new GregorianCalendar(1993, 9, 28).getTime(); for (double i = -12; i < 12; i += 0.25) { Date d = new Date((long) (sDate.getTime() + (i * 6.45 * 1E3 * 60 * 60))); ts.addOrUpdate(new Millisecond(d), tide.getTidePrediction(d, false)); } JPanel panel = new JPanel(new BorderLayout()); timeSeriesChart = ChartFactory.createTimeSeriesChart(null, null, null, tsc, true, true, true); panel.add(new ChartPanel(timeSeriesChart), BorderLayout.CENTER); timeSeriesChart.getXYPlot().addDomainMarker(marker); levelMarker.setValue(TidePredictionFactory.getTideLevel(new Date())); timeSeriesChart.getXYPlot().addRangeMarker(levelMarker); GuiUtils.testFrame(panel); System.out.println("\n________________________________________"); long start = System.currentTimeMillis(); TidCachedData tcd = new TidCachedData(new File(ConfigFetch.getConfFolder() + "mra/Leixoes.tid")); System.out.println("Loading of " + tcd.getName() + " took " + MathMiscUtils.parseToEngineeringNotation((System.currentTimeMillis() - start) / 1E3, 2) + "s"); }
From source file:com.naver.mage4j.core.util.PhpDateUtils.java
public static Integer getElapsedTime(Date startDate, Date endDate) { long diffTime = endDate.getTime() - startDate.getTime(); return (int) (diffTime / (1000 * 60 * 60)); }
From source file:com.esofthead.mycollab.core.utils.DateTimeUtils.java
/** * Trim hour-minute-second of date instance value to zero. * //from www . j a v a 2 s . c om * @param value * @return */ public static Date trimHMSOfDate(Date value) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); try { return df.parse(df.format(value.getTime())); } catch (ParseException e) { throw new MyCollabException(e); } }
From source file:com.parse.ParseKeyValueCache.java
static String loadFromKeyValueCache(final String key, final long maxAgeMilliseconds) { synchronized (MUTEX_IO) { File file = getKeyValueCacheFile(key); if (file == null) { return null; }// www . j av a 2 s. com Date now = new Date(); long oldestAcceptableAge = Math.max(0, now.getTime() - maxAgeMilliseconds); if (getKeyValueCacheAge(file) < oldestAcceptableAge) { return null; } // Update mtime to make the LRU work file.setLastModified(now.getTime()); try { RandomAccessFile f = new RandomAccessFile(file, "r"); byte[] bytes = new byte[(int) f.length()]; f.readFully(bytes); f.close(); return new String(bytes, "UTF-8"); } catch (IOException e) { PLog.e(TAG, "error reading from cache", e); return null; } } }
From source file:edu.lternet.pasta.portal.search.AuthorSearch.java
/** * Updates the authors and organizations values by executing a * Solr query for each.//from w w w . j a v a2 s . c om */ public static void updateAuthorsAndOrganizations() { if (authors.length < 2 || organizations.length < 2 || shouldRefresh(lastRefreshTime)) { try { logger.warn("Begin refreshing creator names cache."); String authorQuery = buildAuthorQuery(); updateAuthors(authorQuery); logger.warn("Finished refreshing creator names cache."); logger.warn("Begin refreshing creator organizations cache."); String organizationQuery = buildOrganizationQuery(); updateOrganizations(organizationQuery); logger.warn("Finished refreshing creator organizations cache."); Date now = new Date(); lastRefreshTime = now.getTime(); } catch (Exception e) { logger.error("Error updating creators and organizations: " + e.getMessage()); e.printStackTrace(); } } }
From source file:nz.co.senanque.validationengine.ConvertUtils.java
public static final String printDate(Date c) { if (c == null) { return null; }/*from w ww . j av a2 s. c o m*/ return s_dateFormat.format(c.getTime()); }
From source file:org.sonatype.nexus.repository.http.HttpConditions.java
@Nullable private static DateTime parseDateHeader(@Nullable final String httpDate) { if (!Strings.isNullOrEmpty(httpDate)) { final Date date = DateUtils.parseDate(httpDate); if (date != null) { return new DateTime(date.getTime()); }// w w w.ja va 2 s. c om } return null; }
From source file:nz.co.senanque.validationengine.ConvertUtils.java
public static final String printDateTime(Date c) { if (c == null) { return null; }/* ww w . ja va 2s . c o m*/ return s_dateTimeFormat.format(c.getTime()); }
From source file:com.coinblesk.server.utilTest.ServerCalls.java
public static VerifyTO verifyServerCallInput(ECKey client, Address p2shAddressTo, Transaction fullTx, Date now) throws UnsupportedEncodingException, Exception { VerifyTO cs = new VerifyTO().publicKey(client.getPubKey()).transaction(fullTx.unsafeBitcoinSerialize()) .currentDate(now.getTime()); SerializeUtils.signJSON(cs, client); return cs;/*from w ww . j a v a 2s . c om*/ }
From source file:com.amazonaws.util.DateUtils.java
/** * Formats the specified date as an RFC 822 string. * * @param date//from w w w. jav a2 s . c om * The date to format. * * @return The RFC 822 string representing the specified date. */ public static String formatRFC822Date(Date date) { try { return rfc822DateFormat.print(date.getTime()); } catch (RuntimeException ex) { throw handleException(ex); } }