Java Date Time

Source: Internet
Author: User

Public Static void Main (string[] args) {

String pattern = "Yyyy-mm-dd HH:mm:ss";

SimpleDateFormat format = new SimpleDateFormat (pattern);

String curdate = Format.format (New Date ());

System.out.println (curdate);

}

Letters

Date or time element

Said

Example

G

Era Marker

Text

AD

Y

Years

Year

1996; 96

M

Month of the Year

Month

July; Jul; 07

W

Number of weeks in the year

Number

27

W

Number of weeks in the month

Number

2

D

Number of days in the year

Number

189

D

Number of days in month

Number

10

F

Week of the Month

Number

2

E

Days of the Week

Text

Tuesday; Tue

A

AM/PM Mark

Text

Pm

H

Number of hours in the day (0-23)

Number

0

K

Number of hours in the day (1-24)

Number

24

K

Number of hours in am/pm (0-11)

Number

0

H

Number of hours in am/pm (1-12)

Number

12

M

Number of minutes in hours

Number

30

S

Number of seconds in minutes

Number

55

S

Number of milliseconds

Number

978

Z

Time

General Time Zone

Pacific Standard Time; PST; gmt-08:00

Z

Time

RFC 822 Time Zone

-0800

Java Date Time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.