We would like to know how to get time from a Date Object.
import java.util.Date; import java.text.SimpleDateFormat; /*from w w w . j a v a 2s . com*/ public class SDF { public static final void main(String[] args) { SimpleDateFormat localDateFormat = new SimpleDateFormat("HH:mm:ss"); String time = localDateFormat.format(new Date()); System.out.println(time); } }
The code above generates the following result.