Date and simpledateformat

Source: Internet
Author: User

Common date methods

Return type

Method Name

Remarks

Date

New Date ()

Create current date object

Date

New Date (long DT)

Use the specified number of milliseconds since January 1, to create a date

Boolean

Before (date D)

Returns true if it is before the specified date.

Boolean

After (date D)

After

Long

Gettime ()

Returns the number of milliseconds from 1970.1.1.

Void

Settime (long time)

Set date

Boolean

Equals (Object OBJ)

Judge whether the date is equal

String

Tostring ()

Format date

 

 

Common Methods of simpledateformat class

Return type

Method Name

Remarks

 

New simpledateformat ()

Create object

 

New simpledateformat (string pattern)

Specify format to create an object

String

Format (Object OBJ)

Format the generated string of an object.

Date

Parse (string text)

Generate a date

Calendar

Getcalendar ()

Get the calendar associated with this date/time formatter

Dateformat

Getinstance ()

Get the short-style default date/time Formatter for date and time

 

 

/************* Date and simpledateformat *****************/
// Public static void main (string [] ARGs ){
// Date = new date ();
// System. Out. println (date); // output the current date
// System. Out. println (date. gettime (); // returns the number of milliseconds since January 1 ,.
//
// Simpledateformat SDF = new simpledateformat ("yyyy-mm-dd hh: mm: SS ");
// System. Out. println (SDF. Format (date); // format the date
//}

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.