[#BloombergLP-bdlt-Datetime-setTimeIfValid]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlt.adoc[bdlt]::xref:BloombergLP/bdlt/Datetime.adoc[Datetime]::setTimeIfValid
:relfileprefix: ../../../
:mrdocs:

Set the &quot;time&quot; part of this object to have the value represented by the specified `hour` attribute value and the optionally specified `minute`, `second`, `millisecond`, and `microsecond` attribute values if they comprise a valid &quot;time&quot; portion of a `DateTime` value&period; Unspecified trailing optional parameters default to 0&period; Return 0 on success, and a non&hyphen;zero value (with no effect) otherwise&period; Note that this method has no effect on the &quot;date&quot; part of this object&period;

== Synopsis

Declared in `&lt;bdlt&lowbar;datetime&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
setTimeIfValid(
    int hour,
    int minute = 0,
    int second = 0,
    int millisecond = 0,
    int microsecond = 0);
----


[.small]#Created with https://www.mrdocs.com[MrDocs]#
