Super easy! The Lao Ma team strongly recommends JAVA "Method of Obtaining Date" (with code)

This article introduces the method of obtaining date in java, friends in need can refer to it


/*
* 获取昨天日期 方法一,这个方法好像有点慢
*/
Date dt = new Date(); 
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
time = new SimpleDateFormat( "yyyy-MM-dd").format(cal.getTime()); 
/*
* 获取昨天日期 方法二
*/
Date as = new Date(new Date().getTime()-24*60*60*1000);
SimpleDateFormat matter1 = new SimpleDateFormat("yyyy-MM-dd"); 
time = matter1.format(as);
            

The latest high-frequency interview questions collected in 2021 (all organized into documents), there are a lot of dry goods, including mysql, netty, spring, thread, spring cloud, jvm, source code, algorithm and other detailed explanations. There are also detailed learning plans and interviews. Questions, etc., friends who need to obtain these content, please add Q Junyang: 547998459

The above is the whole content of this article. If you need more information, please contact me. I hope it will be helpful to everyone's study, and I hope you can support me.

Guess you like

Origin blog.csdn.net/p1830095583/article/details/114527810