Java DateFormat.getTimeInstance()
Syntax
DateFormat.getTimeInstance() has the following syntax.
public static final DateFormat getTimeInstance()
Example
In the following code shows how to use DateFormat.getTimeInstance() method.
// w ww . ja v a 2 s . com
import java.text.DateFormat;
import java.util.Date;
public class Main {
public static void main(String[] argv) throws Exception {
DateFormat dateFormat = DateFormat.getTimeInstance();
String s = dateFormat.format(new Date());
System.out.println(s);
}
}
The code above generates the following result.