congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CalendarDate.getDifferenceInMsecs
Code IndexAdd Tabnine to your IDE (free)

How to use
getDifferenceInMsecs
method
in
ucar.nc2.time.CalendarDate

Best Java code snippets using ucar.nc2.time.CalendarDate.getDifferenceInMsecs (Showing top 12 results out of 315)

origin: edu.ucar/netcdf

/**
 * Find the difference between two dates in hours
 * @param base date1
 * @param forecast date2
 * @return (forecast minus base) difference in hours
 */
public static double getOffsetInHours(CalendarDate base, CalendarDate forecast) {
 long diff = forecast.getDifferenceInMsecs(base);
 return diff / 1000.0 / 60.0 / 60.0;
}
origin: edu.ucar/cdm

/**
 * Find the difference between two dates in hours
 * @param base date1
 * @param forecast date2
 * @return (forecast minus base) difference in hours
 */
public static double getOffsetInHours(CalendarDate base, CalendarDate forecast) {
 long diff = forecast.getDifferenceInMsecs(base);
 return diff / 1000.0 / 60.0 / 60.0;
}
origin: Unidata/thredds

/**
 * Find the difference between two dates in hours
 * @param base date1
 * @param forecast date2
 * @return (forecast minus base) difference in hours
 */
public static double getOffsetInHours(CalendarDate base, CalendarDate forecast) {
 long diff = forecast.getDifferenceInMsecs(base);
 double result =  diff / 1000.0 / 60.0 / 60.0;                // LOOK why convert to double? precision may be lost ??
 long testRoundoff = (long) ( result * 1000.0 * 60.0 * 60.0);
 if (diff != testRoundoff)
  System.out.println("HEY getOffsetInHours");
 return result;
}
origin: Unidata/thredds

public static int getOffset(CalendarDate refDate, CalendarDate cd, CalendarPeriod timeUnit) {
 long msecs = cd.getDifferenceInMsecs(refDate);
 return (int) Math.round(msecs / timeUnit.getValueInMillisecs());
}
origin: edu.ucar/netcdf

/**
 * Subtract two dates, return difference in units of this period.
 * If not even, will round down and log a warning
 * @param start start date
 * @param end   end date
 * @return  difference in units of this period
 */
public int subtract(CalendarDate start, CalendarDate end) {
 long diff = end.getDifferenceInMsecs(start);
 int thislen = millisecs();
 if ((diff % thislen != 0))
  log.warn("roundoff error");
 return (int) (diff / thislen);
}
origin: Unidata/thredds

/**
 * Subtract two dates, return difference in units of this period.
 * If not even, will round down and log a warning
 * @param start start date
 * @param end   end date
 * @return  difference in units of this period
 */
public int subtract(CalendarDate start, CalendarDate end) {
 long diff = end.getDifferenceInMsecs(start);
 int thislen = millisecs();
 if ((diff % thislen != 0))
  log.warn("roundoff error");
 return (int) (diff / thislen);
}
origin: edu.ucar/cdm

/**
 * Subtract two dates, return difference in units of this period.
 * If not even, will round down and log a warning
 * @param start start date
 * @param end   end date
 * @return  difference in units of this period
 */
public int subtract(CalendarDate start, CalendarDate end) {
 long diff = end.getDifferenceInMsecs(start);
 int thislen = millisecs();
 if ((diff % thislen != 0))
  log.warn("roundoff error");
 return (int) (diff / thislen);
}
origin: Unidata/thredds

/**
 * Get difference between two calendar dates in given Field units
 * @param o  other calendar date
 * @return  (this minus o) difference in units of this Field
 */
public long getDifference(CalendarDate o, CalendarPeriod.Field fld) {
 switch (fld) {
  case Millisec:
   return getDifferenceInMsecs(o);
  case Second:
   return (long) (getDifferenceInMsecs(o) / MILLISECS_IN_SECOND);
  case Minute:
   return (long) (getDifferenceInMsecs(o) / MILLISECS_IN_MINUTE);
  case Hour:
   return (long) (getDifferenceInMsecs(o) / MILLISECS_IN_HOUR);
  case Day:
   return (long) (getDifferenceInMsecs(o) / MILLISECS_IN_DAY);
  case Month:
   int tmonth = getFieldValue(CalendarPeriod.Field.Month);
   int omonth = o.getFieldValue(CalendarPeriod.Field.Month);
   int years = (int) this.getDifference(o, CalendarPeriod.Field.Year);
   return tmonth-omonth + 12 * years;
  case Year:
   int tyear = getFieldValue(CalendarPeriod.Field.Year);
   int oyear = o.getFieldValue(CalendarPeriod.Field.Year);
   return tyear - oyear;
 }
 return dateTime.getMillis() - o.dateTime.getMillis();
}
origin: Unidata/thredds

for (Object coord : coords) {
 CalendarDate cd = (CalendarDate) coord;
 long msecs = cd.getDifferenceInMsecs(runDate);
 int val = (int) Math.round(msecs / duration);
 offsets.add(val);
origin: Unidata/thredds

public double makeOffsetFromRefDate( CalendarDate date) {
 if (isCalendarField) {
  if (date.equals(baseDate)) return 0.0;
  return date.getDifference(baseDate, periodField);
 } else {
  long msecs = date.getDifferenceInMsecs(baseDate);
  return msecs / period.getValueInMillisecs();
 }
}
origin: Unidata/thredds

private void testCalendar(Calendar cal, String s) {
 CalendarDateUnit cdu;
 try {
  cdu = CalendarDateUnit.withCalendar(cal, s);
 } catch (Exception e) {
  e.printStackTrace();
  return;
 }
 System.out.printf("%s == %s unit (cal=%s)%n", s, cdu, cdu.getCalendar());
 CalendarDate base = null;
 for (int i = 0; i < 13; i++) {
  CalendarDate cd = cdu.makeCalendarDate(i);
  if (base == null) base = cd;
  double diff = cd.getDifferenceInMsecs(base) * 1.0e-6;
  System.out.printf(" %d %s == %s diff = %f%n", i, cdu, CalendarDateFormatter.toDateTimeStringISO(cd), diff);
 }
 System.out.printf("%n");
}
origin: Unidata/thredds

extract.extract(sdata);
CalendarDate date = extract.makeCalendarDate();
if (Math.abs(date.getDifferenceInMsecs(today)) > 1000L * 3600 * 24 * 100) {
 extract.makeCalendarDate();
ucar.nc2.timeCalendarDategetDifferenceInMsecs

Javadoc

Get difference between two calendar dates in millisecs

Popular methods of CalendarDate

  • getMillis
    Gets the milliseconds of the datetime instant from the Java epoch of 1970-01-01T00:00:00Z.
  • of
  • toString
    ISO formatted string
  • parseISOformat
    Get CalendarDate from ISO date string
  • add
  • equals
  • isAfter
  • getCalendar
  • isBefore
  • toDate
    Get the equivilent java.util.Date
  • compareTo
  • getDateTime
  • compareTo,
  • getDateTime,
  • getHourOfDay,
  • parseUdunits,
  • present,
  • withDoy,
  • <init>,
  • getDifference,
  • getFieldValue

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSystemService (Context)
  • startActivity (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now