Jodatime Excellent date frame

Source: Internet
Author: User
Tags current time datetime
Not much nonsense, please read the code directly, there are questions please leave a message, the author will be as soon as possible to help you solve the lease.
Java code    package com.baidu.test;      import java.util.date;      import org.joda.time.datetime;   import org.joda.time.format.datetimeformat;      /**   *    *  @author   Park Heiling    * 2011-02-13    * baidu   *   */   public class testjodatime {        public static void main (String[] args)  {            datetime dt = new datetime ();//   Get current time               //  According to the specified format, Convert a time string to a DateTime object            DateTime dt2 =  Datetimeformat.forpattern ("Yyyy-mm-dd hh:mm:ss"). ParseDateTime ("1985-12-26 23:23:31");              //  years, months, days, hours, minutes, seconds, milliseconds             datetime dt3 = new datetime (2011, 2, 13, 10, 30,  50, 333);// 2010 February 13 10:30 50 sec 333 msec                //  Judging if leap month            DATETIME DT4  = new datetime ();            Org.joda.time.datetime.property month = dt4.monthofyear ();            SYSTEM.OUT.PRINTLN ("Whether leap month:"  + month.isleap ());               //  get  3 seconds ago             datetime dt5 = dt.secondofminute (). Addtocopy ( -3);            dt.gEtsecondofminute ();//  get full minutes after the number of seconds             Dt.getsecondofday ();//  get a full day after the number of seconds             Dt.secondofminute ();//  get minute objects, such as making leap year judgments, etc. use                // datetime and Java.util.Date objects, current system Timemillis conversion             datetime dt6 = new datetime (New date ());            date date = dt.todate ();            datetime dt7 = new datetime (System.currenttimemillis ());            dt.getmillis ();               //  the DT object, output the string in the specified format             system.out.println (Dt.tostring ("Yyyy-mm-dd hh:mm:ss "));          }  }  
Related Article

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.