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

The following examples show how to use javax.xml.bind.DatatypeConverter#printTime() . 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
Source File: StructuredQueryBuilder.java    From java-client-api with Apache License 2.0 6 votes vote down vote up
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 File: XmlTimeTypeAdapter.java    From cia with 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
Source File: DataTypeAdapterCXF.java    From govpay with GNU General Public License v3.0 5 votes vote down vote up
public static String printTime(Date dt) {
    if (dt == null) {
        return null;
    }
    Calendar c = Calendar.getInstance();
    c.setTime(dt);
    return DatatypeConverter.printTime(c);
}
 
Example 4
Source File: DataTypeAdapter.java    From govpay with GNU General Public License v3.0 5 votes vote down vote up
public static String printTime(Date dt) {
    if (dt == null) {
        return null;
    }
    Calendar c = Calendar.getInstance();
    c.setTime(dt);
    return DatatypeConverter.printTime(c);
}
 
Example 5
Source File: DataTypeAdapterCXF.java    From govpay with GNU General Public License v3.0 5 votes vote down vote up
public static String printTime(Date dt) {
    if (dt == null) {
        return null;
    }
    Calendar c = Calendar.getInstance();
    c.setTime(dt);
    return DatatypeConverter.printTime(c);
}
 
Example 6
Source File: DataTypeAdapter.java    From govpay with GNU General Public License v3.0 5 votes vote down vote up
public static String printTime(Date dt) {
    if (dt == null) {
        return null;
    }
    Calendar c = Calendar.getInstance();
    c.setTime(dt);
    return DatatypeConverter.printTime(c);
}
 
Example 7
Source File: TimeStringAsCalendar.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String marshal(Calendar time) throws Exception {
	if (time == null) {
		return null;
	} else {
		return DatatypeConverter.printTime(time);
	}
}
 
Example 8
Source File: DateUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 9
Source File: DateUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 10
Source File: DateUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 11
Source File: DateUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 12
Source File: DateUtils.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String printTime(DateTime dateTime) {
   return dateTime == null ? null : DatatypeConverter.printTime(convert(dateTime));
}
 
Example 13
Source File: XsValueImpl.java    From java-client-api with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return DatatypeConverter.printTime(value);
}