Java Code Examples for ucar.nc2.time.CalendarDate#getMillis()
The following examples show how to use
ucar.nc2.time.CalendarDate#getMillis() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecordDatasetHelper.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
private double getTime(StructureMembers.Member timeVar, StructureData sdata) { if (timeVar == null) return 0.0; if ((timeVar.getDataType() == DataType.CHAR) || (timeVar.getDataType() == DataType.STRING)) { String time = sdata.getScalarString(timeVar); CalendarDate date = CalendarDateFormatter.isoStringToCalendarDate(null, time); if (date == null) { log.error("Cant parse date - not ISO formatted, = " + time); return 0.0; } return date.getMillis() / 1000.0; } else { return sdata.convertScalarDouble(timeVar); } }
Example 2
Source File: NestedTable.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
private double getTime(CoordVarExtractor cve, StructureData[] tableData) { if (cve == null) return Double.NaN; if (tableData[cve.nestingLevel] == null) return Double.NaN; if (cve.isString()) { String timeString = timeVE.getCoordValueString(tableData); CalendarDate date = CalendarDateFormatter.isoStringToCalendarDate(null, timeString); if (date == null) { log.error("Cant parse date - not ISO formatted, = " + timeString); return 0.0; } return date.getMillis(); } else { return cve.getCoordValue(tableData); } }
Example 3
Source File: DecoderWrapper.java From sis with Apache License 2.0 | 6 votes |
/** * Returns the value of the attribute of the given name as a date, or {@code null} if none. * * @param name the name of the attribute to search, or {@code null}. * @return the attribute value, or {@code null} if none or unparsable or if the given name was null. */ @Override public Date dateValue(final String name) { if (name != null) { for (final Group group : groups) { final Attribute attribute = findAttribute(group, name); if (attribute != null && attribute.isString()) { String value = Utils.nonEmpty(attribute.getStringValue()); if (value != null) { final CalendarDate date; try { date = CalendarDateFormatter.isoStringToCalendarDate(Calendar.proleptic_gregorian, value); } catch (IllegalArgumentException e) { listeners.warning(e); continue; } return new Date(date.getMillis()); } } } } return null; }
Example 4
Source File: BufrFeatureDatasetFactory.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected PointFeature makeFeature(int recnum, StructureData sdata) throws IOException { extract.extract(sdata); String stationId = extract.getStationId(); if (!stationId.equals(s.getName())) return null; CalendarDate date = extract.makeCalendarDate(); return new BufrStationPoint(s, date.getMillis(), 0, munger.munge(sdata)); // LOOK obsTime, nomTime }
Example 5
Source File: BufrFeatureDatasetFactory.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected PointFeature makeFeature(int recnum, StructureData sdata) throws IOException { extract.extract(sdata); String stationId = extract.getStationId(); StationFeature want = stationsWanted.getStation(stationId); if (want == null) return null; CalendarDate date = extract.makeCalendarDate(); countHere++; return new BufrPoint(want, date.getMillis(), 0, munger.munge(sdata)); }
Example 6
Source File: BufrConfig.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void processSeq(StructureDataIterator sdataIter, FieldConverter parent, boolean isTop) throws IOException { try { while (sdataIter.hasNext()) { StructureData sdata = sdataIter.next(); if (isTop) { countObs++; if (hasStations) processStations(parent, sdata); if (hasDate) { extract.extract(sdata); CalendarDate date = extract.makeCalendarDate(); if (Math.abs(date.getDifferenceInMsecs(today)) > 1000L * 3600 * 24 * 100) { extract.makeCalendarDate(); } long msecs = date.getMillis(); if (this.start > msecs) { this.start = msecs; } if (this.end < msecs) { this.end = msecs; } } } int count = 0; for (StructureMembers.Member m : sdata.getMembers()) { if (m.getDataType() == DataType.SEQUENCE) { FieldConverter fld = parent.getChild(count); ArraySequence data = (ArraySequence) sdata.getArray(m); int n = data.getStructureDataCount(); fld.trackSeqCounts(n); processSeq(data.getStructureDataIterator(), fld, false); } count++; } } } finally { sdataIter.close(); } }
Example 7
Source File: CoordinateTime2D.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 4 votes |
public Time2D(CalendarDate refDate, Integer time, TimeCoordIntvValue tinv) { this.refDate = refDate.getMillis(); this.time = time; this.tinv = tinv; }