/** * Get ISO formatted string * * @return ISO formatted date */ public String toDateTimeStringISO() { return date.toString(); }
@Override public String getUnit() { return periodName+" since "+firstDate.toString(); }
/** * Get the string name for the ith time coordinate. * * @param index which time coordinate * @return time name. * @deprecated */ public String getTimeName(int index) { List<CalendarDate> cdates = getCalendarDates(); if ((index < 0) || (index >= cdates.size())) throw new IllegalArgumentException("getTimeName illegal index = " + index); return cdates.get(index).toString(); }
/** * Get the string name for the ith time coordinate. * * @param index which time coordinate * @return time name. * @deprecated */ public String getTimeName(int index) { List<CalendarDate> cdates = getCalendarDates(); if ((index < 0) || (index >= cdates.size())) throw new IllegalArgumentException("getTimeName illegal index = " + index); return cdates.get(index).toString(); }
/** * Get the index corresponding to the time name. * * @param name time name * @return time index, or -1 if not found * @deprecated */ public int getTimeIndex(String name) { List<CalendarDate> cdates = getCalendarDates(); for (int i=0; i < cdates.size(); i++) { if( cdates.get(i).toString().equals(name)) return i; } return -1; }
/** * Get the string name for the ith time coordinate. * * @param index which time coordinate * @return time name. * @deprecated */ public String getTimeName(int index) { List<CalendarDate> cdates = getCalendarDates(); if ((index < 0) || (index >= cdates.size())) throw new IllegalArgumentException("getTimeName illegal index = " + index); return cdates.get(index).toString(); }
/** * Get the index corresponding to the time name. * * @param name time name * @return time index, or -1 if not found * @deprecated */ public int getTimeIndex(String name) { List<CalendarDate> cdates = getCalendarDates(); for (int i=0; i < cdates.size(); i++) { if( cdates.get(i).toString().equals(name)) return i; } return -1; }
/** * Get the index corresponding to the time name. * * @param name time name * @return time index, or -1 if not found * @deprecated */ public int getTimeIndex(String name) { List<CalendarDate> cdates = getCalendarDates(); for (int i=0; i < cdates.size(); i++) { if( cdates.get(i).toString().equals(name)) return i; } return -1; }
/** * Get the list of time names, to be used for user selection. * The ith one refers to the ith time coordinate. * * @return List of ucar.nc2.util.NamedObject, or empty list. */ public List<NamedObject> getTimes() { List<CalendarDate> cdates = getCalendarDates(); List<NamedObject> times = new ArrayList<>( cdates.size()); for (CalendarDate cd: cdates) { times.add(new ucar.nc2.util.NamedAnything(cd.toString(), "calendar date")); } return times; }
/** * Get the list of time names, to be used for user selection. * The ith one refers to the ith time coordinate. * * @return List of ucar.nc2.util.NamedObject, or empty list. */ public List<NamedObject> getTimes() { List<CalendarDate> cdates = getCalendarDates(); List<NamedObject> times = new ArrayList<NamedObject>( cdates.size()); for (CalendarDate cd: cdates) { times.add(new ucar.nc2.util.NamedAnything(cd.toString(), "calendar date")); } return times; }
/** * Get the list of time names, to be used for user selection. * The ith one refers to the ith time coordinate. * * @return List of ucar.nc2.util.NamedObject, or empty list. */ public List<NamedObject> getTimes() { List<CalendarDate> cdates = getCalendarDates(); List<NamedObject> times = new ArrayList<>( cdates.size()); for (CalendarDate cd: cdates) { times.add(new ucar.nc2.util.NamedAnything(cd.toString(), "calendar date")); } return times; }
private CalendarDateUnit(Calendar calt, CalendarPeriod.Field periodField, CalendarDate baseDate) { this.cal = calt; this.periodField = periodField; this.baseDate = baseDate; String periodName; if (periodField == CalendarPeriod.Field.Month || periodField == CalendarPeriod.Field.Year) { periodName = "calendar "+ periodField.toString(); isCalendarField = true; } else { periodName = periodField.toString(); isCalendarField = false; } unitString = periodName + " since " + baseDate.toString(); }
@Test public void test360bug() { CalendarDateUnit unit = CalendarDateUnit.withCalendar(Calendar.uniform30day, "days since 2289-12-1"); CalendarDate cd1 = unit.makeCalendarDate(25200.0); // 70 years = 2359-12-1 CalendarDate cd2 = unit.makeCalendarDate(46800.0); // 130 = 2419-12-1 System.out.printf("%s%n", unit); System.out.printf("%s%n", cd1); System.out.printf("%s%n", cd2); assert cd1.toString().equals("2359-12-01T00:00:00Z"); assert cd2.toString().equals("2419-12-01T00:00:00Z"); }
@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); }
private Element genTemporalDomainElem(CoordinateAxis1DTime timeAxis) { // temporalDomain Element temporalDomainElem = new Element("temporalDomain", wcsNS); List<CalendarDate> dates = timeAxis.getCalendarDates(); // temporalDomain/timePosition [1..*] for (CalendarDate curDate : dates) { temporalDomainElem.addContent( new Element("timePosition", gmlNS).addContent(curDate.toString())); } return temporalDomainElem; }
private Element genTemporalDomainElem(CoordinateAxis1DTime timeAxis) { // temporalDomain Element temporalDomainElem = new Element("temporalDomain", wcsNS); List<CalendarDate> dates = timeAxis.getCalendarDates(); // temporalDomain/timePosition [1..*] for (CalendarDate curDate : dates) { temporalDomainElem.addContent( new Element("timePosition", gmlNS).addContent(curDate.toString())); } return temporalDomainElem; }
@Test public void doit() { DateExtractorFromName de = new DateExtractorFromName(dateFormatMark, useName); CalendarDate d = de.getCalendarDateFromPath(name); logger.debug("{} == {}", name, d); assert d.toString().equals(result); } }
private String makeTimeCoord(Grib1ParamTime ptime) { CalendarPeriod period = GribUtils.getCalendarPeriod(getTimeUnit()); CalendarDateUnit unit = CalendarDateUnit.of(null, period.getField(), getReferenceDate()); int timeCoord; if (ptime.isInterval()) { int[] intv = ptime.getInterval(); CalendarDate cdate1 = unit.makeCalendarDate(period.getValue() * intv[0]); CalendarDate cdate2 = unit.makeCalendarDate(period.getValue() * intv[1]); return "(" + cdate1.toString() + "," + cdate2.toString() + ")"; } else { timeCoord = ptime.getForecastTime(); CalendarDate cdate = unit.makeCalendarDate(period.getValue() * timeCoord); return cdate.toString(); } }
@Test public void testFeatureCollectionConfig() throws IOException { FeatureCollectionConfig config = new FeatureCollectionConfig("fnmoc", "test/fnmoc", FeatureCollectionType.GRIB1, "[DATA_DIR]/native/grid/FNMOC/COAMPS/Equatorial_America/FNMOC_COAMPS_Equatorial_America_#yyyyMMdd_HHmm#.grib1", null, null, null, "file", null); DateExtractor extractor = config.getDateExtractor(); String path = "[DATA_DIR]/native/grid/FNMOC/COAMPS/FNMOC_COAMPS_Equatorial_America_20141207_1200.grib1.ncx3"; MFile mfile = new MFileOS7(Paths.get(path), null); CalendarDate cd = extractor.getCalendarDate(mfile); assert cd != null : "date extractor failed"; System.out.printf("%s -> %s%n", path, cd); assert(cd.toString().equals("2014-12-07T12:00:00Z")); }
public String getTimeCoord() { if (isTimeInterval()) return getTimeIntervalDates().toString(); else return getForecastDate().toString(); }