public static String getFormattedTime() {
Calendar calendar = Calendar.getInstance(); // use user locale
// SimpleDateFormat simpledateformat = new
// SimpleDateFormat("yyyy-MM-dd'T'HH':'mm':'ss'.'SSSz");
SimpleDateFormat simpledateformat = new SimpleDateFormat(
"yyyy-MM-dd'T'HH':'mm':'ss'.'SSSSSS");
return simpledateformat.format(calendar.getTime());// .replaceAll("GMT",
// "T");
}
private static final MessageFormat TAG_MF =
new MessageFormat(
"<tag><tagId>{0}</tagId><dateTime>{1}</dateTime></tag>");
public static String formatTag2XML(String line, CallbackLog log) {
if(line != null && line.length() > 0)
{
String [] tagInfo = {"tag:"+line,getFormattedTime()};
return TAG_MF.format(tagInfo);
}
return null;
/*
String formattedStr = null;
String[] parts = null;
String[] nameAndAntenna = null;
String canonicalTagId = null;
parts = StringUtils.split(line, '|');
if (parts != null && parts.length == 3) { // format correct
canonicalTagId = formatTagId(parts[0], parts[2]);
nameAndAntenna = new String[] { canonicalTagId, parts[1] };
formattedStr = TAG_MF.format(nameAndAntenna);
} else {
String msg = "tag's format isn't correct";
String[] params = new String[] { "originalLine=" + line };
log.warn(DeviceLogCategory.DA_TAG_ID, msg, params);
}
return formattedStr;
*/
}