Java Get yesterday date

Source: Internet
Author: User

    <div class="article_title">        <span class="ico ico_type_Repost"></span>        
 <div class="category clearfix"> <div class="bog_copyright"> </div> <div id="article_content" class="article_content csdn-tracking-statistics" data-pid="blog" data-mod="popu_307" data-dsm="post"> <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/production/htmledit_views-0a60691e80.css"> <div class="htmledit_views"> 

Transferred from: http://blog.sina.com.cn/s/blog_6d416c1e01019zod.html

Take yesterday's date, the cut-off date of this thought is good. Another thought wrong, if today is a number what to do?
Two options available
1: The Old method

  Date as = new Date (new Date (). GetTime () -24*60*60*1000);
  SimpleDateFormat matter1 = new SimpleDateFormat ("Yyyy-mm-dd");
  String time = Matter1.format (AS);
  SYSTEM.OUT.PRINTLN (time);
  Take out the digital time   minus the 24*60*60*1000, you get the time yesterday;
This is a bit out of date!
2:calendar   cal   =   calendar.getinstance ();
  Cal.add (calendar.date,  -1);
  String yesterday = new SimpleDateFormat ("Yyyy-mm-dd"). Format (Cal.gettime ());
  SYSTEM.OUT.PRINTLN (yesterday);
This method is very convenient, month and day can be arbitrary change!
3, with Apache Dateutils (requires import org.apache.commons.lang.time.DateUtils;)
  Date currenttime = Apputils.getcurrentdate ();
 //Get yesterday time
  Date backuptime=dateutils.adddays (CurrentTime,-1);
 
4.sql query condition contains the processing method of the time:
Select * from TBIMC1 where Create_date_<to_date (To_char (sysdate-1, ' yyyy-mm-dd ') , ' Yyyy-mm-dd ')

 </div> </div> <div class= "Readall_box csdn-tracking-statistics tracking-click ReadAll _BOX_NOBG "data-pid=" blog "data-mod=" popu_596 "style=" Display:none; " > <div class= "read_more_mask" ></div> <a class= "btn btn-large btn-gray-fred read_more_btn" Targ et= "_self" > Read full text </a> </div> <ul class= "Article_next_prev" > <li class= "Prev_article" > <span onclick= "_gaq.push ([' _trackevent ', ' function ', ' onclick ', ' Blog_articles_shan Gyipian ']); location.href= ' 51974085 '; " > Previous </span> <a href= "51974085" onclick= "_gaq.push ([' _trackevent ', ' function ', ' onclick ', ' blog_artic Les_shangyipian ']) ">the specified child already have a parent. You must call Removeview () on the child ' s parent first.</a> </li> <li class= "Next_article" > <span onclick= "_gaq.push ([' _trackevent ', ' function', ' onclick ', ' Blog_articles_xiayipian ']); location.href= ' 51989061 '; " > Next </span> <a href= "51989061" onclick= "_gaq.push ([' _trackevent ', ' function ', ' onclick ', ' blog_artic Les_xiayipian ']) ">scrollview nested listview issues </a> </li> </ul> <div style=" Clea R:both; height:10px; " ></div></div>

Java gets yesterday's date

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.