nynw.net
当前位置:首页 >> jAvA获取当前时间加半小时之后的时间 >>

jAvA获取当前时间加半小时之后的时间

不用那么繁杂的操作,下面即可: Calendar now=Calendar.getInstance(); now.add(Calendar.MINUTE,30); SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateStr=sdf.format(now.getTimeInMillis()); System.out.pri...

Calendar calendar = Calendar.getInstance(); /* HOUR_OF_DAY 指示一天中的小时 */ calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Syste...

Calendar cal = Calendar.getInstance(); cal.add(Calendar.Date, 30); Date date = cal.getTime();

Calendar c = Calendar.getInstance();//可以对每个时间域单独修改 int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int date = c.get(Calendar.DATE); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Cale...

java获取当前时间加半小时之后的时间: 1、获取当前时间,获取到的时间类型是long类型的,单位是毫秒 long currentTime = System.currentTimeMillis() ; 2、在这个基础上加上30分钟: currentTime +=30*60*1000; 3、格式化时间,获取到的就是当...

推迟一周示例:Calendar curr = Calendar.getInstance();curr.set(Calendar.DAY_OF_MONTH,curr.get(Calendar.DAY_OF_MONTH)+7);Date date=curr.getTime(); 推迟一年示例:Calendar curr = Calendar.getInstance();curr.set(Calendar.YEAR,curr.g...

利用Calendar类,新创建一个Calendar对象,就是当前时间,然后用add方法,添加一个DAY_OF_YEAR类型的1,就可以了。

SimpleDateFormat dft = new SimpleDateFormat("yyyy-MM-dd"); Date beginDate = new Date(); Calendar date = Calendar.getInstance(); date.setTime(beginDate); date.set(Calendar.DATE, date.get(Calendar.DATE) - 1); Date endDate = dft.p...

long currentTime = System.currentTimeMillis() + 30 * 60 * 1000; Date date = new Date(currentTime); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String nowTime=""; nowTime= df.format(date); System.out.println(now...

import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;public class DateTest {public static void main(String[] args) {Date date = new Date();Calendar cal = Calendar.getInstance();cal.setTime(date);//d...

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