164
164
return buffer.toString();
168
* Is the provided value a valid date-and-or-time, as per the spec?
170
* @param value the value
171
* @return true if it is
173
protected boolean isValidDateAndOrTime( String value )
175
// ISO 8601:2004 4.1.2 date with 4.1.2.3 a) and b) reduced accuracy
177
"[0-9]{4}(?:-?[0-9]{2}(?:-?[0-9]{2})?)?";
179
// ISO 8601:2000 5.2.1.3 d), e) and f) truncated date representation
181
"--(?:[0-9]{2}(?:-?[0-9]{2})?|-[0-9]{2})";
183
// ISO 8601:2004 4.2.2 time with 4.2.2.3 reduced accuracy, 4.2.4 UTC and
184
// 4.2.5 zone offset, no 4.2.2.4 decimal fraction and no 4.2.3 24:00
187
"(?:[0-1][0-9]|2[0-3])(?::?[0-5][0-9](?::?(?:60|[0-5][0-9]))?)?" +
188
"(?:Z|[-+](?:[0-1][0-9]|2[0-3])(?::?[0-5][0-9])?)?";
190
// ISO 8601:2000 5.3.1.4 a), b) and c) truncated time representation
192
"-(?:[0-5][0-9](?::?(?:60|[0-5][0-9]))?|-(?:60|[0-5][0-9]))";
194
// RFC6350 (vCard 3.0) date-and-or-time with mandatory time designator
195
String date_and_or_time =
196
"(?:" + date + "|" + date_trunc + ")?" +
197
"(?:T(?:" + time + "|" + time_trunc + "))?";
199
return value.matches( date_and_or_time );
168
203
protected boolean exportContact( ContactData contact )
169
204
throws AbortExportException
288
323
for( int a = 0; a < notes.size(); a++ )
289
324
out.append( fold( "NOTE:" + escape( notes.get( a ) ) ) + "\n" );
327
String birthday = contact.getBirthday().trim();
328
if( birthday != null ) {
329
if( isValidDateAndOrTime( birthday ) )
330
out.append( fold( "BDAY:" + escape( birthday ) ) + "\n" );
333
fold( "BDAY;VALUE=text:" + escape( birthday ) ) + "\n" );
292
337
out.append( "END:VCARD\n" );