Java Code Examples for javax.xml.bind.DatatypeConverter#printTime()

The following examples show how to use javax.xml.bind.DatatypeConverter#printTime() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
String formatValue(Object value, String type) {
  if ( value == null ) {
    return "null";
  }
  Class<?> valClass = value.getClass();
  if ( String.class.isAssignableFrom(valClass) ) {
    return (String) value;
  } else if ( type != null &&
    ( type.endsWith("date") || type.endsWith("dateTime") || type.endsWith("time") ) &&
    ( Date.class.isAssignableFrom(valClass) || Calendar.class.isAssignableFrom(valClass) ) )
  {
    if ( Date.class.isAssignableFrom(valClass) ) {
      Calendar cal = Calendar.getInstance();
      cal.setTime((Date) value);
      value = cal;
    }
    if ( type.endsWith("date") ) {
      return DatatypeConverter.printDate((Calendar) value);
    } else if ( type.endsWith("dateTime") ) {
      return DatatypeConverter.printDateTime((Calendar) value);
    } else if ( type.endsWith("time") ) {
      return DatatypeConverter.printTime((Calendar) value);
    }
  }
  return value.toString();
}
 
Example 2
Source Project: cia   File: XmlTimeTypeAdapter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String marshal(final Date dt) {
	if (dt == null) {
		return null;
	}
	final Calendar c = Calendar.getInstance();
	c.setTime(dt);
	return DatatypeConverter.printTime(c);
}
 
Example 3
public static String printTime(Date dt) {
    if (dt == null) {
        return null;
    }
    Calendar c = Calendar.getInstance();
    c.setTime(dt);
    return DatatypeConverter.printTime(c);
}
 
Example 4
public static String printTime(Date dt) {
    if (dt == null) {
        return null;
    }
    Calendar c = Calendar.getInstance();
    c.setTime(dt);
    return DatatypeConverter.printTime(c);
}
 
Example 5
public static String printTime(Date dt) {
    if (dt == null) {
        return null;
    }
    Calendar c = Calendar.getInstance();
    c.setTime(dt);
    return DatatypeConverter.printTime(c);
}
 
Example 6
public static String printTime(Date dt) {
    if (dt == null) {
        return null;
    }
    Calendar c = Calendar.getInstance();
    c.setTime(dt);
    return DatatypeConverter.printTime(c);
}
 
Example 7
@Override
public String marshal(Calendar time) throws Exception {
	if (time == null) {
		return null;
	} else {
		return DatatypeConverter.printTime(time);
	}
}
 
Example 8
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 9
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 10
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 11
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 12
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 13
Source Project: java-client-api   File: XsValueImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return DatatypeConverter.printTime(value);
}