SimpleDateFormat format minute
In this chapter you will learn:
Formatting Minutes using SimpleDateFormat
The following code uses the m
and mm
flags to format minutes.
import java.text.SimpleDateFormat;
import java.util.Date;
/* j av a2 s .c o m*/
public class Main {
public static void main(String[] args) {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("m");
System.out.println("minutes in m format : " + sdf.format(date));
sdf = new SimpleDateFormat("mm");
System.out.println("minutes in mm format : " + sdf.format(date));
}
}
The output:
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » Date, Time