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

How to use
CalendarPeriod
in
ucar.nc2.time

Best Java code snippets using ucar.nc2.time.CalendarPeriod (Showing top 20 results out of 315)

origin: Unidata/thredds

PeriodType getPeriodType() {
 return getField().p;
}
origin: Unidata/thredds

private CalendarDateUnit(Calendar calt, CalendarPeriod.Field periodField, CalendarDate baseDate) {
 this.cal = calt;
 this.periodField = periodField;
 this.period = CalendarPeriod.of(1, periodField);
 this.baseDate = baseDate;
 if (periodField == CalendarPeriod.Field.Month || periodField == CalendarPeriod.Field.Year) {
  isCalendarField = true;
 } else {
  isCalendarField = false;
 }
}
origin: Unidata/thredds

 public static void main(String[] args) {
  CalendarPeriod cp = CalendarPeriod.of(1, Field.Day);
  CalendarDate start =  CalendarDate.parseUdunits(null, "3 days since 1970-01-01 12:00");
  CalendarDate end =  CalendarDate.parseUdunits(null, "6 days since 1970-01-01 12:00");
  int offset = cp.getOffset(start, end);
  System.out.printf("offset=%d%n", offset);
 }
}
origin: edu.ucar/netcdf

public CalendarPeriod getTimeUnit() {
 return CalendarPeriod.of(1, CalendarPeriod.fromUnitString(unitString));
}
origin: edu.ucar/netcdf

 public static void main(String[] args) {
  CalendarPeriod cp = new CalendarPeriod(1, Field.Day);
  CalendarDate start =  CalendarDate.parseUdunits(null, "3 days since 1970-01-01 12:00");
  CalendarDate end =  CalendarDate.parseUdunits(null, "6 days since 1970-01-01 12:00");
  int offset = cp.getOffset(start, end);
  System.out.printf("offset=%d%n", offset);
 }
}
origin: Unidata/thredds

public String getTimeIntervalName() {
 if (!isInterval()) return null;
 // are they the same length ?
 int firstValue = -1;
 boolean same = true;
 for (Tinv tinv : intervals) {
  int value = (tinv.b2 - tinv.b1);
  if (firstValue < 0) firstValue = value;
  else if (value != firstValue) same = false;
 }
 if (same) {
  firstValue = (firstValue * calendarPeriod.getValue());
  return firstValue + "_" + calendarPeriod.getField().toString();
 } else {
  return CoordinateTimeAbstract.MIXED_INTERVALS;
 }
}
origin: edu.ucar/netcdf

private List<CollectionManager> makePartitionsByPeriod() throws IOException {
 this.type = Type.timePeriod;
 List<DatedMFile> files = new ArrayList<DatedMFile>();
 for (MFile mfile : getFiles()) {
  CalendarDate cdate = dateExtractor.getCalendarDate(mfile);
  if (cdate == null)
   logger.error("Date extraction failed on file= {} dateExtractor = {}", mfile.getPath(), dateExtractor);
  files.add( new DatedMFile(mfile, cdate));
 }
 Collections.sort(files);
 CalendarDateFormatter cdf = new CalendarDateFormatter("yyyyMMdd");
 List<CollectionManager> result = new ArrayList<CollectionManager>();
 TimePartitionCollectionManager curr = null;
 for (DatedMFile dmf : files) {
  if ((curr == null) || (!curr.endPartition.isAfter(dmf.cdate))) {
   CalendarPeriod period = CalendarPeriod.of(config.timePartition);
   CalendarDate start = dmf.cdate.truncate(period.getField()); // start on a boundary
   CalendarDate end = start.add( period);
   String name = collectionName + "-"+ cdf.toString(dmf.cdate);
   curr = new TimePartitionCollectionManager(name, start, end, getRoot(), this.auxInfo, this.logger);
   result.add(curr);
  }
  curr.add(dmf);
 }
 return result;
}
origin: Unidata/thredds

public Tinv convertReferenceDate(CalendarDate refDate, CalendarPeriod timeUnit) {
 if (timeUnit == null) return null;
 int startOffset = timeUnit.getOffset(refDate, start);   // LOOK wrong - not dealing with value ??
 int endOffset = timeUnit.getOffset(refDate, end);
 return new TimeCoord.Tinv(startOffset, endOffset);
}
origin: Unidata/thredds

public int getOffset(CalendarDate start, CalendarDate end) {
 if (start.equals(end)) return 0;
 long start_millis = start.getDateTime().getMillis();
 long end_millis = end.getDateTime().getMillis();
 // 5 second slop
 Period p;
 if (start_millis < end_millis)
  p = new Period(start_millis, end_millis + 5000, getPeriodType());
 else
  p = new Period(start_millis+5000, end_millis, getPeriodType());
 return p.get(getDurationFieldType());
}
origin: edu.ucar/cdm

/**
 * Get the duration in seconds                                               -+
 * @return the duration in seconds
 * @deprecated dont use because these are fixed length and thus approximate.
 */
public double getValueInMillisecs() {
  if (field == CalendarPeriod.Field.Month)
   return 30.0 * 24.0 * 60.0 * 60.0 * 1000.0 * value;
  else if (field == CalendarPeriod.Field.Year)
   return 365.0 * 24.0 * 60.0 * 60.0 * 1000.0 * value;
  else return millisecs();
 }
origin: Unidata/thredds

if (timeUnitPeriod.equals(CalendarPeriod.Hour)) return range;
if (timeUnitPeriod.getField() == CalendarPeriod.Field.Month) {
 fac = 30.0 * 24.0;  // nominal hours in a month
} else if (timeUnitPeriod.getField() == CalendarPeriod.Field.Year) {
 fac = 365.0 * 24.0; // nominal hours in a year
} else {
 fac = CalendarPeriod.Hour.getConvertFactor(timeUnitPeriod);
origin: Unidata/thredds

@Override
public CalendarDateRange makeCalendarDateRange(ucar.nc2.time.Calendar cal) {
 CalendarDateUnit cdu = CalendarDateUnit.withCalendar(cal, periodName + " since " + refDate.toString());
 CalendarDate start = cdu.makeCalendarDate(timeUnit.getValue() * offsetSorted.get(0));
 CalendarDate end = cdu.makeCalendarDate(timeUnit.getValue() * offsetSorted.get(getSize() - 1));
 return CalendarDateRange.of(start, end);
}
origin: edu.ucar/netcdf

/**
 * Multiply the period by an integer
 * @param value multiply by this
 * @return new period
 */
public CalendarPeriod multiply(int value) {
 return new CalendarPeriod(this.value * value, this.field);
}
origin: edu.ucar/netcdf

public static CalendarDuration fromUnitString(String unitString) {
 return new CalendarDuration(1, CalendarPeriod.fromUnitString(unitString));
}
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: Unidata/thredds

/**
 * Check if we all time intervals have the same length.
 * @return time interval name or MIXED_INTERVALS
 */
public String getTimeIntervalName() {
 // are they the same length ?
 int firstValue = -1;
 for (TimeCoord.Tinv tinv : timeIntervals) {
  int value = (tinv.getBounds2() - tinv.getBounds1());
  if (firstValue < 0) firstValue = value;
  else if (value != firstValue) return MIXED_INTERVALS;
 }
 firstValue = (firstValue * timeUnit.getValue());
 return firstValue + "_" + timeUnit.getField().toString();
}
origin: edu.ucar/cdm

public CalendarPeriod getTimeUnit() {
 return CalendarPeriod.of(1, CalendarPeriod.fromUnitString(unitString));
}
origin: Unidata/thredds

@Override
public TimeCoord.TinvDate getForecastTimeInterval(Grib2Record gr) {
 Grib2Pds pds = gr.getPDS();
 if (!pds.isTimeInterval()) return null;
 int[] intv = getForecastTimeIntervalOffset(gr);
 assert intv != null;
 int intvLen = intv[1]-intv[0];
 int timeUnitOrg = pds.getTimeUnit();
 int timeUnitConvert = convertTimeUnit(timeUnitOrg);
 CalendarPeriod unitPeriod = Grib2Utils.getCalendarPeriod(timeUnitConvert);
 if (unitPeriod == null)
  throw new IllegalArgumentException("unknown CalendarPeriod "+timeUnitConvert+ " org="+timeUnitOrg);
 CalendarPeriod.Field fld = unitPeriod.getField();
 CalendarDate start = gr.getReferenceDate().add(intv[0], fld);
 CalendarPeriod period = CalendarPeriod.of(intvLen, fld);
 return new TimeCoord.TinvDate(start, period);
}
origin: Unidata/thredds

public double getOffsetInTimeUnits(CalendarDate start) {
 return timeUnit.getOffset(start, getRefDate());
}
////////////////////////////////////////
origin: edu.ucar/netcdf

public int getOffset(CalendarDate start, CalendarDate end) {
 Period p = new Period(start.getDateTime(), end.getDateTime(), getPeriodType());
 return p.get(getDurationFieldType());
}
ucar.nc2.timeCalendarPeriod

Javadoc

A CalendarPeriod is a logical duration of time, it requires a Calendar to convert to an actual duration of time. A CalendarField is expressed as {integer x Field}. Design follows joda Period class.

Most used methods

  • getField
  • getValue
  • of
  • getOffset
  • <init>
  • fromUnitString
    Convert a period string into a CalendarPeriod.Field.
  • getDurationFieldType
  • getPeriodType
  • millisecs
  • getValueInMillisecs
    Get the duration in seconds -+
  • equals
  • getConvertFactor
    Get the conversion factor of the other CalendarPeriod to this one
  • equals,
  • getConvertFactor,
  • multiply,
  • toString

Popular in Java

  • Reading from database using SQL prepared statement
  • getApplicationContext (Context)
  • getSystemService (Context)
  • requestLocationUpdates (LocationManager)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • JTextField (javax.swing)
  • Runner (org.openjdk.jmh.runner)
  • Top PhpStorm plugins
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