Java Code Examples for ucar.nc2.time.CalendarDate#present()
The following examples show how to use
ucar.nc2.time.CalendarDate#present() .
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: CFPointWriter.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void finish() throws IOException { if (llbb != null) { writer.updateAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLowerLeftPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getUpperRightPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLowerLeftPoint().getLongitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getUpperRightPoint().getLongitude())); } if (!noTimeCoverage) { if (minDate == null) minDate = CalendarDate.present(); if (maxDate == null) maxDate = CalendarDate.present(); writer.updateAttribute(null, new Attribute(ACDD.TIME_START, CalendarDateFormatter.toDateTimeStringISO(minDate))); writer.updateAttribute(null, new Attribute(ACDD.TIME_END, CalendarDateFormatter.toDateTimeStringISO(maxDate))); } writer.close(); }
Example 2
Source File: WriterCFPointAbstract.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void finish() throws IOException { if (llbb != null) { writer.updateAttribute(null, new Attribute(ACDD.LAT_MIN, llbb.getLowerLeftPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LAT_MAX, llbb.getUpperRightPoint().getLatitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MIN, llbb.getLowerLeftPoint().getLongitude())); writer.updateAttribute(null, new Attribute(ACDD.LON_MAX, llbb.getUpperRightPoint().getLongitude())); } if (!config.isNoTimeCoverage()) { if (minDate == null) minDate = CalendarDate.present(); if (maxDate == null) maxDate = CalendarDate.present(); writer.updateAttribute(null, new Attribute(ACDD.TIME_START, CalendarDateFormatter.toDateTimeStringISO(minDate))); writer.updateAttribute(null, new Attribute(ACDD.TIME_END, CalendarDateFormatter.toDateTimeStringISO(maxDate))); } writer.close(); }
Example 3
Source File: DefaultDateRangeTest.java From tds with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SpringJUnit4ParameterizedClassRunner.Parameters public static List<Object[]> getTestParameters() { CalendarDate now = CalendarDate.present(); CalendarDate dayAfter = now.add(CalendarPeriod.of(1, CalendarPeriod.Field.Day)); CalendarDate dayBefore = now.add(CalendarPeriod.of(-1, CalendarPeriod.Field.Day)); String nowStr = CalendarDateFormatter.toDateTimeStringISO(now); String dayAfterStr = CalendarDateFormatter.toDateTimeStringISO(dayAfter); String dayBeforeStr = CalendarDateFormatter.toDateTimeStringISO(dayBefore); return Arrays .asList(new Object[][] {{0L, null, "present", "present", null}, {86400L, null, "present", dayAfterStr, null}, {86400L, null, dayBeforeStr, "present", null}, {86400L * 2, null, dayBeforeStr, dayAfterStr, null}, {86400L * 3, null, nowStr, null, "P3D"}, {86400L * 2, null, null, dayBeforeStr, "P2D"}}); }
Example 4
Source File: VariableTable.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * */ DateRenderer() { oldForm = new CalendarDateFormatter("yyyy-MM-dd HH:mm:ss", CalendarTimeZone.UTC); newForm = new CalendarDateFormatter("dd MMM HH:mm:ss", CalendarTimeZone.UTC); CalendarDate now = CalendarDate.present(); cutoff = now.add(-1, CalendarPeriod.Field.Year); // "now" time format within a year }
Example 5
Source File: StructureTable.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
DateRenderer() { oldForm = new CalendarDateFormatter("yyyy MMM dd HH:mm", CalendarTimeZone.UTC); newForm = new CalendarDateFormatter("MMM dd, HH:mm", CalendarTimeZone.UTC); CalendarDate now = CalendarDate.present(); cutoff = now.add(-1, CalendarPeriod.Field.Year); // "now" time format within a year }
Example 6
Source File: NcTimePositionType.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static TimePositionType initTimePosition(TimePositionType timePosition) { CalendarDate resultTime = MarshallingUtil.fixedResultTime; if (resultTime == null) { resultTime = CalendarDate.present(); // Initialized to "now". } // TEXT timePosition.setStringValue(resultTime.toString()); return timePosition; }
Example 7
Source File: NcDocumentMetadataType.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static DocumentMetadataType initDocumentMetadata(DocumentMetadataType documentMetadata) { // @gml:id String id = MarshallingUtil.createIdForType(DocumentMetadataType.class); documentMetadata.setId(id); // wml2:generationDate CalendarDate generationDate = MarshallingUtil.fixedGenerationDate; if (generationDate == null) { generationDate = CalendarDate.present(); // Initialized to "now". } documentMetadata.setGenerationDate(generationDate.toGregorianCalendar()); return documentMetadata; }
Example 8
Source File: NcssGridParamsBean.java From tds with BSD 3-Clause "New" or "Revised" License | 5 votes |
public CalendarDate getRuntimeDate(Calendar cal) { if (runtimeDate == null) return null; if (cal.equals(Calendar.getDefault())) return runtimeDate; // otherwise must reparse if (getTime().equalsIgnoreCase("present")) { return CalendarDate.present(cal); } return CalendarDateFormatter.isoStringToCalendarDate(cal, getRuntime()); }
Example 9
Source File: RadarServerController.java From tds with BSD 3-Clause "New" or "Revised" License | 5 votes |
CalendarDate parseTime(String timeString) { if (timeString == null) return null; if (timeString.equalsIgnoreCase("present")) { return CalendarDate.present(); } else { return CalendarDate.parseISOformat(null, timeString); } }
Example 10
Source File: TimeParamsValidator.java From tds with BSD 3-Clause "New" or "Revised" License | 4 votes |
private static CalendarDate isoString2Date(String isoString) { if ("present".equalsIgnoreCase(isoString)) return CalendarDate.present(); return CalendarDateFormatter.isoStringToCalendarDate(Calendar.getDefault(), isoString); }
Example 11
Source File: DateType.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Get this as a CalendarDate * * @return CalendarDate */ public CalendarDate getCalendarDate() { return isPresent() ? CalendarDate.present() : date; }