Java Issues Collection Ⅰ

Source: Internet
Author: User

1, Java Date added

import java.util.Date;d ate=new Date (); //  Calendar Calendar   =   new   GregorianCalendar (); Calendar.settime (date); Calendar.add (Calendar. DATE,1); //  date=calendar.gettime ();   // this time is the result of a day pushing the date backwards.

2. String to date or date to string

This conversion uses the Java.text.SimpleDateFormat class string to convert to a date type: Method 1: Also the simplest method date Date=NewDate ("2008-04-14"); method 2:simpledateformat SDF=NewSimpleDateFormat ("YYYY-MM-DD");//The lowercase mm represents the minuteString dstr="2008-4-24"; java.util.Date Date=Sdf.parse (DSTR); date converted to string: SimpleDateFormat SDF=NewSimpleDateFormat ("YYYY-MM-DD"); Java.util.Date Date=Newjava.util.Date (); String Str=sdf.format (date);

Java Issues Collection Ⅰ

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.