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

How to use
CalendarDateFormatter
in
ucar.nc2.time

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

origin: edu.ucar/cdm

public CalendarDate makeCalendarDateFromOffset(String offset) {
 return CalendarDateFormatter.isoStringToCalendarDate(calendar, offset);
}
origin: Unidata/thredds

public static void main(String arg[]) {
 CalendarDate cd = CalendarDate.present();
 /* {"S", "M", "L", "F", "-"}
 System.out.printf("%s%n", DateTimeFormat.forStyle("SS").print(cd.getDateTime()));
 System.out.printf("%s%n", DateTimeFormat.forStyle("MM").print(cd.getDateTime()));
 System.out.printf("%s%n", DateTimeFormat.forStyle("LL").print(cd.getDateTime()));
 System.out.printf("%s%n", DateTimeFormat.forStyle("FF").print(cd.getDateTime())); */
 System.out.printf("%s%n", cd);
 System.out.printf("toDateTimeStringISO=%s%n", toDateTimeStringISO(cd));
 System.out.printf("   toDateTimeString=%s%n", toDateTimeString(cd));
 System.out.printf("       toDateString=%s%n", toDateString(cd));
 System.out.printf("        toTimeUnits=%s%n", toTimeUnits(cd));
 System.out.printf("===============================%n");
 Date d = cd.toDate();
 System.out.printf("cd.toDate()=%s%n", toDateTimeString(d));
 SimpleDateFormat udunitDF = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
 udunitDF.setTimeZone(TimeZone.getTimeZone("UTC"));
 udunitDF.applyPattern("yyyy-MM-dd HH:mm:ss.SSS 'UTC'");
 System.out.printf("           udunitDF=%s%n", udunitDF.format(d));
 System.out.printf("===============================%n");
 DateFormatter df = new DateFormatter();
 System.out.printf("     toTimeUnits(date)=%s%n", toTimeUnits(cd));
 System.out.printf("toDateTimeString(date)=%s%n", df.toDateTimeString(d));
 System.out.printf("toDateOnlyString(date)=%s%n", df.toDateOnlyString(d));
}
origin: Unidata/thredds

static public String makeName(String collectionName, CalendarDate runtime) {
 String nameNoBlanks = StringUtil2.replace(collectionName, ' ', "_");
 return nameNoBlanks + "-" + cf.toString(runtime);
}
origin: edu.ucar/netcdf

/**
 * Same as DateFormatter.toDateOnlyString()
 *
 * @return formatted date
 */
public String toDateString() {
 if (isPresent())
  return CalendarDateFormatter.toDateStringPresent();
 else
  return CalendarDateFormatter.toDateString(date);
}
origin: edu.ucar/netcdf

public static void main(String arg[]) {
 CalendarDate cd = CalendarDate.present();
 /* {"S", "M", "L", "F", "-"}
 System.out.printf("%s%n", DateTimeFormat.forStyle("SS").print(cd.getDateTime()));
 System.out.printf("%s%n", DateTimeFormat.forStyle("MM").print(cd.getDateTime()));
 System.out.printf("%s%n", DateTimeFormat.forStyle("LL").print(cd.getDateTime()));
 System.out.printf("%s%n", DateTimeFormat.forStyle("FF").print(cd.getDateTime())); */
 System.out.printf("%s%n", cd);
 System.out.printf("%s%n", toDateTimeStringISO(cd));
 System.out.printf("%s%n", toDateTimeString(cd));
 System.out.printf("%s%n", toDateString(cd));
 Date d = new Date();
 System.out.printf("%s%n", toDateTimeString(d));
 DateFormatter df = new DateFormatter();
 System.out.printf("%s%n", df.toDateTimeString(d));
 System.out.printf("%s%n", df.toDateOnlyString(d));
}
origin: Unidata/thredds

@Test
public void testCalendarToDate() {
 CalendarDate cdate = CalendarDateFormatter.isoStringToCalendarDate(Calendar.uniform30day, "1968-01-30T15:00:00.000Z");
 System.out.printf("%s%n", cdate);
 System.out.printf("%s%n", cdate.getDateTime());
 System.out.printf("%s%n", cdate.toDate());
 System.out.printf("%s%n", CalendarDateFormatter.toDateTimeStringISO(cdate.toDate()));
 System.out.printf("%s%n", CalendarDateFormatter.toDateString(cdate));
 CalendarDateFormatter cdf = new CalendarDateFormatter("yyyyMMdd");
 System.out.printf("%s%n", cdf.toString(cdate));
}
origin: edu.ucar/cdm

/**
 * ISO formatted string
 * @return ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZ)
 */
@Override
public String toString() {
 return CalendarDateFormatter.toDateTimeStringISO(this);
}
origin: Unidata/thredds

private void assertAddReturnsExpectedDate(String baseDate, double value, Field units, String expectedResult) {
 CalendarDate base = CalendarDateFormatter.isoStringToCalendarDate(Calendar.gregorian, baseDate);
 CalendarDate result = base.add(value, units);
 assertEquals(units.toString(), expectedResult, CalendarDateFormatter.toDateTimeStringISO(result));
}
origin: Unidata/thredds

logger.debug("tc = {}", tc);
CalendarDate got = tc.getStart().getCalendarDate();
CalendarDate want = CalendarDateFormatter.isoStringToCalendarDate(null, "1999-11-16T12:00:00");
assert got.equals(want);
assert tc.getResolution() == null;
assert CalendarDateFormatter.toDateString(start).equals("2017-02-30");
assert CalendarDateFormatter.toDateString(end).equals("2017-04-01");
origin: edu.ucar/cdm

/**
 * Return a string with a reasonable and complete representation of the
 * given <code>Date</code>, shown in UTC.
 *
 * @param date <code>Date</code> to be represented
 * @return a string containing the representation of the date
 */
public static String formatDate(Date date) {
 return CalendarDateFormatter.toDateTimeString(date);
}
origin: edu.ucar/netcdf

public static CalendarDate parseISOformatOld(String calendarName, String isoDateString) {
  // Date date = CalendarDateFormatter.parseISODate(isoDateString);
   java.util.Date date = CalendarDateFormatter.isoStringToDate(isoDateString);
  Calendar cal = Calendar.get(calendarName);
  Chronology chronology = Calendar.getChronology(cal);
  DateTime dt = new DateTime(date, chronology);
  return new CalendarDate(cal, dt);
 }
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

boolean scheduleWrite(Message m) throws IOException {
 CalendarDate cd = m.ids.getReferenceTime();
 String writerName = (dayRollover) ? fileout + "." + CalendarDateFormatter.toDateString(cd) : fileout;
    File dir2 = new File(dispatchDir, catDir);
    if (!dir2.exists() && !dir2.mkdirs()) logger.warn("Failed to make " + dir2.getPath());
    String filename = (dayRollover) ? fileout + "." + CalendarDateFormatter.toDateString(cd) : fileout;
    file2write = new File(dir2, filename + ".bufr");
origin: edu.ucar/netcdf

DateTime dt = parseIsoTimeString(calt, iso);
return new CalendarDate(calt, dt);
origin: Unidata/thredds

static public CalendarDateFormatter factory(CalendarPeriod period) {
 switch (period.getField()) {
  case Year: return new CalendarDateFormatter("yyyy");
  case Month: return new CalendarDateFormatter("yyyy-MM");
  case Day: return new CalendarDateFormatter("yyyy-MM-dd");
  case Hour: return new CalendarDateFormatter("yyyy-MM-ddTHH");
  default: return new CalendarDateFormatter("yyyy-MM-ddTHH:mm:ss");
 }
}
origin: edu.ucar/netcdf

/**
 * ISO formatted string
 * @return ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZ)
 */
@Override
public String toString() {
 return CalendarDateFormatter.toDateTimeStringISO(this);
}
origin: edu.ucar/cdm

/**
 * Same as DateFormatter.toDateOnlyString()
 *
 * @return formatted date
 */
public String toDateString() {
 if (isPresent())
  return CalendarDateFormatter.toDateStringPresent();
 else
  return CalendarDateFormatter.toDateString(date);
}
origin: Unidata/thredds

/**
 * Return a string with a reasonable and complete representation of the
 * given <code>Date</code>, shown in UTC.
 *
 * @param date <code>Date</code> to be represented
 * @return a string containing the representation of the date
 */
public static String formatDate(Date date) {
 return CalendarDateFormatter.toDateTimeString(date);
}
origin: edu.ucar/cdm

public static CalendarDate parseISOformatOld(String calendarName, String isoDateString) {
  // Date date = CalendarDateFormatter.parseISODate(isoDateString);
   java.util.Date date = CalendarDateFormatter.isoStringToDate(isoDateString);
  Calendar cal = Calendar.get(calendarName);
  Chronology chronology = Calendar.getChronology(cal);
  DateTime dt = new DateTime(date, chronology);
  return new CalendarDate(cal, dt);
 }
origin: Unidata/thredds

 DateTime dt = parseIsoTimeString(calt, iso);
Calendar useCal = Calendar.of(dt.getChronology());
 return new CalendarDate(useCal, dt);
ucar.nc2.timeCalendarDateFormatter

Javadoc

Threadsafe static routines for date formatting. Replacement for ucar.nc2.units.DateFormatter

Most used methods

  • isoStringToCalendarDate
    Convert an ISO formatted String to a CalendarDate.
  • toDateString
  • isoStringToDate
    Does not handle non-standard Calendars
  • toDateTimeStringISO
  • toString
  • <init>
  • parseIsoTimeString
  • toDateStringPresent
  • toDateTimeString
  • parseISODate
    Old version using DateFormatter
  • toTimeUnits
    udunits formatting
  • factory
  • toTimeUnits,
  • factory

Popular in Java

  • Reading from database using SQL prepared statement
  • findViewById (Activity)
  • getSystemService (Context)
  • setScale (BigDecimal)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JButton (javax.swing)
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Github Copilot alternatives
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