1. 程式人生 > >JAVA中日期 yyyy-MM-dd HH:mm:ss和yyyy-MM-dd hh:mm:ss的區別

JAVA中日期 yyyy-MM-dd HH:mm:ss和yyyy-MM-dd hh:mm:ss的區別

pac color test orm nbsp spa div rbegin println

JAVA中日期 yyyy-MM-dd HH:mm:ss和yyyy-MM-dd hh:mm:ss的區別 :

HH:24小時制

hh:12小時制

package time;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by sheting on 10/20/2017
 */
public class Test {
    public static void main(String[] args) {
        // hh 是12小時制
DateFormat dateTimeformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); String strBeginDate = dateTimeformat.format(new Date()); System.out.println(strBeginDate); //2017-10-20 11:59:23 // HH 是24小時制 DateFormat dateTimeformat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String strBeginDate2
= dateTimeformat2.format(new Date()); System.out.println(strBeginDate2); //2017-10-20 11:59:23 } }

JAVA中日期 yyyy-MM-dd HH:mm:ss和yyyy-MM-dd hh:mm:ss的區別