zdly.net
当前位置:首页 >> jAvA 一个小时 >>

jAvA 一个小时

private static final String formatStr = "HH:mm"; private static SimpleDateFormat sdf=new SimpleDateFormat(formatStr); public static void main(String args[]) throws ParseException { String tS = "13:00"; String tE = "13:10"; if(i...

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...

SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date=null; try { date = sdf.parse("2012-07-25 21:00:00"); } catch (ParseException e) { // TODO 自动生成 catch 块 e.printStackTrace(); } Calendar ca=Calendar...

public static void main(String[] args) { SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar c=Calendar.getInstance(); System.out.println(sdf.format(c.getTime())); c.add(Calendar.HOUR_OF_DAY, -1);//1小时...

class Yugi{ private static void print(int h,int m,int s){ int ss = h * 60 * 60 + m * 60 + s; System.out.format("%d小时%d分%d秒等于%d秒%n",h,m,s,ss); } private static void print(int s){ int h = s/60/60; int m = s/60%60; int ss =...

java 定时器 Timer timer = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { System.out.println("需要执行的任务"); } }; timer.schedule(task, 60*60*1000);

实现思路:就是将这个数看做一个整数,之后依次对3600(1小时等于3600秒),60,60求余得到对应的数值 public class Time { public static void main(String [] args){ int h=12862/3600; int m=(123456%3600)/60; int s=(123456%3600)%60; Syste...

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...

Calendar begin=Calendar.getInstance(); begin.setTime(....);//给定起始时间 //比如100小时 for(int i=0;i

给时间加个格式: Date date =new Date(System.currentTimeMillis()); SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss "); String time = formatter.format(date); System.out.println(time); 这样你要取整的话 , ...

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