Simpledateformat class for Java API Learning

Source: Internet
Author: User

The following are common methods for the simpledateformat class:

Package util; import Java. text. simpledateformat; import Java. util. date;/***** @ author yjmao * @ deprecated simpledateformat abstract class usage (commonly used methods) * @ version v1.0.0 */public class learnsimpledateformat {public static void main (string [] ARGs) {simpledateformat format = new simpledateformat ("yyyy-mm-dd hh: mm: SS "); Date = new date (); // convert the date type to string: Format () string fdate = format. format (date); system. err. println ("fdate =" + fdate); // converts a string-type date to date: parse () Try {string time = "12:15:54"; Date ftime = format. parse (time); system. err. println ("ftime =" + ftime);} catch (exception e) {}// returns the pattern string topattern () string pattern = format that describes the date format. topattern (); system. err. println ("pattern =" + pattern); // apply the given pattern string to the date format applypattern () simpledateformat apply = new simpledateformat (); Date d = new date (); string dd = apply. format (d); system. err. println ("Default format:" + apply. topattern (); system. err. println ("DD =" + dd); apply. applypattern ("yyyy/mm/DD"); system. err. println ("Format:" + apply. topattern (); string DDD = apply. format (d); system. err. println ("DDD =" + DDD );}}

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.