This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Don: The problem is that "msecs since <date>" already assumes a calendar. so it doesnt make sense to put it into a calendar AFAIU. Where do you get that msecs from ? the CalendarDate always uses UTC, but parseIsoTimeString() will translate from other time zones in the string. ill look at your other stuff when i can. john > John- > > I concur that hiding the underlying implementation is good which is why > I'm trying to use your CalendarDate classes. > > I have msecs (possibly from a java.util.Date or from a VisAD > DateTime.getValue()) and a Calendar. So, I was trying to do: > > org.joda.time.DateTime dt = new org.joda.time.DateTime(msecs, > DateTimeZone.UTC); > return CalendarDate.of(cal, dt); > > since I can't call the ctor. Having signatures of: > > public static CalendarDate of(Calendar, Date) > > and > > public static CalendarDate of(Calendar, msecs) > > would help and hide the underlying implementaion. If you wanted to keep > the existing signatures, then you could just pass along null for > Calendar to the current signatures. > > Also, having a CalendarTimeZone that wraps the Joda DateTimeZone (or > whatever future JSR you use) would be helpful. Right now it seems like > you assume that all times are in UTC, but many datasets that I've > encountered (particularly point data) have their times in local time. > > Also, for formatting on output, the IDV supports specifying the > TimeZone. It would be useful to have a method in CalendarDateFormatter > which would take a custom format string and a timezone, something like: > > public static String formattedString(CalendarDate cd, String pattern, > CalendarTimeZone tz) { > DateTimeFormatter mydf = > DateTimeFormat.forPattern(pattern).withZone(CalendarTimeZone.getDateTimeZone()); > return mydf.print(cd.getDateTime()); > > } > > Thanks. > > Don > > > On 10/26/12 5:00 PM, Unidata netCDF Java Support wrote: > > Hi Don: > > > > The idea is not to let any Joda classes escape the package, since we will > > replace it with JSR-310 when its ready. > > > > Im not sure what you need to do to get a CalendarDate. Currently there are > > 2 ways to get a non-standard CalendarDate: > > > > in CalendarDate class: > > > > public static CalendarDate of(Calendar cal, int year, int monthOfYear, > > int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute); > > > > in CalendarDateFormatter class: > > > > public static CalendarDate isoStringToCalendarDate(Calendar calt, String > > iso) throws IllegalArgumentException; > > > > let me know what you are starting from and we can figure it out. > > > > John > > > >> John- > >> > >> I'm trying to use ucar.nc2.time.CalendarDate in the IDV to support the > >> non-standard calendars since you've done all the heavy lifting there for > >> supporting the joda time stuff. In the end, I have to create VisAD > >> objects that wrap the CalendarDate. My plan is to hold instances of > >> CalendarDate in the visad.DateTime subclass, but I've run into a problem > >> trying to create CalendarDate objects with a non-null Calendar. Both > >> the of(Calendar, DateTime) and the constructor CalendarDate(Calendar, > >> DateTime) are package protected and all the other of() methods don't > >> support passing in a calendar. Could you at the least make the > >> of(Calendar, DateTime) public and/or add Calendar signatures to the > >> other of() methods that take msecs and java.util.Date. > >> > >> Also, how do I build ncIdv.jar through maven? > >> > >> Thanks. > >> > >> Don > >> -- > >> Don Murray > >> NOAA/ESRL/PSD and CIRES > >> 303-497-3596 > >> http://www.esrl.noaa.gov/psd/people/don.murray/ > >> > >> > > > > > > Ticket Details > > =================== > > Ticket ID: TVQ-727289 > > Department: Support netCDF Java > > Priority: Normal > > Status: Open > > > > -- > Don Murray > NOAA/ESRL/PSD and CIRES > 303-497-3596 > http://www.esrl.noaa.gov/psd/people/don.murray/ > > Ticket Details =================== Ticket ID: TVQ-727289 Department: Support netCDF Java Priority: Normal Status: Open