Time format in the United States--complex format date conversion uses the Date.parse ("complex format") method.

Source: Internet
Author: User
Tags dateformat

Use this method


    Long time = Date.parse ("Sun Feb 10:31:58 +0800)";
    SimpleDateFormat sdf=new SimpleDateFormat ("Yyyy-mm-dd");
    Date d = new date (time);
    System.out.println (Sdf.format (d));


Time format in the United States

G Era identifier Text AD
Y year 1996; 96
M years of the month Month July; June June; 07
Number of weeks in W year 27
Number of weeks in the W month 2
Number of days in D year 189
Days in D of month Number 10
Week number 2 in the F month
Days of E week Text Tuesday; Tue
A am/pm tagged Text pm
H hours in a day (0-23) number 0
K Hours in a day (1-24) Number 24
Hours in K-am/pm (0-11) number 0
H am/pm hours (1-12) Number 12
Minutes in M-hour number 30
s minutes in seconds number 55
S milliseconds number 978
Z Time zone zone Pacific Standard; PST; gmt-08:00
Z timezone RFC 822 time zone-0800


DateFormat df = dateformat.getdatetimeinstance (Dateformat.full, Dateformat.full, Locale.china);

SimpleDateFormat SDF = new SimpleDateFormat ("EEE MMM dd HH:mm:ss zzzzz", yyyy);
Date D;
try {

D = Sdf.parse ("Sun Feb 26 10:31:58 +0800 2012");
Long date = D.gettime ();
catch (ParseException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}


The above writing, if not add the red part of the parameter, the conversion will be an error ~


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.