nynw.net
当前位置:首页 >> JAVA取得昨天的当前时间? >>

JAVA取得昨天的当前时间?

首先是讲现在时间的毫秒值求出来设为a, 一天的毫秒值是24 * 60 * 60 * 1000 等于b a-b,之后再做转化, new date(a-b)

昨天 Date date=new Date();//取时间Calendar calendar = new GregorianCalendar();calendar.setTime(date);calendar.add(calendar.DATE,-1);//把日期往后增加一天.整数往后推,负数往前移动date=calendar.getTime(); //这个时间就是日期往后推一...

import java.util.Calendar; public class test { /** * @param args */ public void doing(){ Calendar cal=Calendar.getInstance(); System.out.println((cal.get(cal.MONTH)+1)+"月"+(cal.get(cal.DATE )-1)+"日"+cal.get(cal.HOUR_OF_DAY) +...

JAVAimport java.text.Format;import java.text.SimpleDateFormat;import java.util.Calendar;public class $ { public static void main(String[] args) { Format f = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(...

getdatetime()

方法一: Date date=new Date(); String ss= ""+date.getTime(); Calendar c = Calendar.getInstance(); long l = c.getTimeInMillis(); 方法二: Date dt= new Date(); Long time= dt.getTime(); Long time2=System.currentTimeMillis(); 这里...

public class Test {public static void main(String[] args) {java.util.Calendar rightNow = java.util.Calendar.getInstance();java.text.SimpleDateFormat sim = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//得到当前时间,+3...

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");//昨天Calendar calendar = Calendar.getInstance();calendar.add(Calendar.DATE, -1);System.out.println(dateFormat.format(calendar.getTime()));//本月第一天calendar.cl...

Calendar c_yestaday = Calendar.getInstance(); c_yestaday=昨天的时间 int aa=c_yestaday.add(c_yestaday .DAY_OF_YEAR, 1);//昨天的天数加1 Calendar c_today= Calendar.getInstance(); c_today=jin天的时间 int bb=c_today.DAY_OF_WEEK//今...

网站首页 | 网站地图
All rights reserved Powered by www.nynw.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com