/** * Same as DateFormatter.toDateOnlyString() * * @return formatted date */ public String toDateString() { if (isPresent()) return CalendarDateFormatter.toDateStringPresent(); else return CalendarDateFormatter.toDateString(date); }
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)); }
/** * Same as DateFormatter.toDateOnlyString() * * @return formatted date */ public String toDateString() { if (isPresent()) return CalendarDateFormatter.toDateStringPresent(); else return CalendarDateFormatter.toDateString(date); }
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)); }
/** * Same as DateFormatter.toDateOnlyString() * * @return formatted date */ public String toDateString() { if (isPresent()) return CalendarDateFormatter.toDateStringPresent(); else return CalendarDateFormatter.toDateString(date); }
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");
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)); }
@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)); }
assert CalendarDateFormatter.toDateString(start).equals("2017-02-30"); assert CalendarDateFormatter.toDateString(end).equals("2017-04-01");