Small white dots encountered in Java development

Source: Internet
Author: User
Tags date1 dateformat

Here is mainly their own personal development encountered some small problems, their own to save up, to make up for their weak Java foundation, the great God do not laughed at

1. DateFormat formatted HH and HH differences:
 Public Static Booleancompare_date (String DATE1, String DATE2) {DateFormat df=NewSimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"); Try{Date dt1=Df.parse (DATE1); Date DT2=Df.parse (DATE2); if(Dt1.gettime () <Dt2.gettime ()) {                return true; }        } Catch(Exception Exception) {exception.printstacktrace (); }        return false; }

Previously written in a time-size method, occasionally found that it should be returned to Ture, but return false. Especially if one of them has a time of 12.

// 12-hour system New SimpleDateFormat ("Yyyy-mm-dd hh:mm:ss"); // 24-hour system New SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");

Later found that he did not pay special attention to the meaning of HH and hh, paste copy, it was written as hh, self-confessed 12:30 will be translated into 00:30.

2. To be Continued ...

I will continue to update, I met, more embarrassing, but also to make their own unforgettable problems

Small white dots encountered in Java development

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.