Time formatting error: Unknown pattern letter: T

1,361 views
Skip to first unread message

Dylan Pugh

unread,
Sep 15, 2021, 9:29:54 AM9/15/21
to ERDDAP
Hi Everyone,

I'm running into an issue when trying to add a new csv dataset to my ERDDAP instance:

 IllegalArgumentException: Unknown pattern letter: T
 at gov.noaa.pfel.erddap.dataset.EDD.fromXml(EDD.java:443)
 at gov.noaa.pfel.erddap.LoadDatasets.run(LoadDatasets.java:353)
Caused by: java.lang.IllegalArgumentException: Unknown pattern letter: T
 at com.cohort.util.Calendar2.makeDateTimeFormatter(Calendar2.java:6050)
 at gov.noaa.pfel.erddap.variable.EDVTimeStamp.<init>(EDVTimeStamp.java:227)

Here's an example of a time entry in the underlying data: 

2012-06-11T13:14:00-05:00

and the relevant chunk of datasets.xml:

<dataVariable>
       <sourceName>time</sourceName>
       <destinationName>time</destinationName>
       <dataType>String</dataType>
       <!-- sourceAttributes>
       </sourceAttributes -->
       <addAttributes>
             <att name="ioos_category">Time</att>
             <att name="long_name">Time</att>
             <att name="standard_name">time</att>
             <att name="time_precision">1970-01-01T00:00:00Z</att>
             <att name="units">yyyy-MM-dd&#39;T&#39;HH:mm:ssxxx</att>
        </addAttributes>
</dataVariable>

I've also tried this format for the "units" attribute:  yyyy-MM-dd'T'HH:mm:ss-05:00.

The confusing thing is that I've used the same date format, and same xml for other datasets, which have loaded properly, so I'm struggling to zero in on the issue. I've tested this on ERDDAP 2.10 & 2.11.

I've attached the relevant chunk of datasets.xml (for the whole dataset), the full error output, and the truncated dataset csv I'm using for testing. Any help/insight would be appreciated. 

Thanks!


datasets_xml_chunk.xml
erddap_error.txt
MIN_WBTS_DMAC_2005-2017_CFIN_FINAL_8SEP21.csv

Mathew Biddle - NOAA Affiliate

unread,
Sep 15, 2021, 9:43:23 AM9/15/21
to Dylan Pugh, ERDDAP
I've run into that a lot in the past, dealing with tabular files with odd date formats. I don't recall what my particular solution was, but I would recommend trial and error using this tool https://coastwatch.pfeg.noaa.gov/erddap/convert/time.html

For example, this https://coastwatch.pfeg.noaa.gov/erddap/convert/time.html?stringTime=2012-06-11T13%3A14%3A00-05%3A00 gives you what the units should look like for this datum: yyyy-MM-dd'T'HH:mm:ssxxx

Sometimes it's an encoding issue...

Hope this helps.

Matt

--
You received this message because you are subscribed to the Google Groups "ERDDAP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erddap+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/erddap/6a6ec1e5-13de-4804-ac98-06a76dfaed6dn%40googlegroups.com.


--
Mathew Biddle, Data Management Analyst
NOAA/NOS
US Integrated Ocean Observing System Office
1315 East-West Highway
Silver Spring MD 20910

ORCiD: 0000-0003-4897-1669
Contractor, Integrated Systems Solutions

Bob Simons

unread,
Sep 15, 2021, 10:35:23 AM9/15/21
to ERDDAP
The problem is with the units string that you have supplied in datasets.xml.
The units string for a String time variable tells ERDDAP the format of the String time data values.
For example, the correct format for an ISO 8601 formatted string value like 2021-09-15T14:33:00Z is 
      yyyy-MM-dd'T'HH:mm:ssZ
where yyyy indicates a 4 digit year, MM indicates a 2 digit month, etc. 
So the letters in the format (AKA the pattern) are symbols which have meanings. 
If you have a literal character in a String time values, you must enclose it in single quotes in the units string, as with 'T' in the example format above. 

Thus, the single parentheses around the literal 'T' are what you forgot in your units string.
Hence ERDDAP's error message: "Unknown pattern letter: T".

Regarding how to create the appropriate units string:
I don't recommend trial and error.
I do recommend using GenerateDatasetsXml to generate the datasets.xml. 
It will determine the correct format automatically (this was added after Matt Biddle did all his work at BCO-DMO, where he could have used this feature).
Or, you can use the underlying tool which determines the correct format which can be found by itself in ERDDAP's Time Converter.
The third option there lets you enter a time string in any format and have ERDDAP convert it into an ISO 8601-formatted time string.
For example,
      Convert any common string time 
      into an ISO 8601 string time. 
If you enter 
      1/2/1985 00:00:00
it replies
      1/2/1985 00:00:00 @ M/d/yyyy H:m:s = 1985-01-02T00:00:00Z       
Note that it tells you the format that it deduced ("M/d/yyyy H:m:s" in this case) is in the output line.

I hope that helps.
Reply all
Reply to author
Forward
0 new messages