---
title: "java获得当前时间一小时前的时间"
author: "daoshud1"
date: "2013-10-29T15:30:51Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2013-10-29T15:30:51Z"
id: 1966114
url: "https://daoshud1.iteye.com/blog/1966114"
---

```java

Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		calendar.set(Calendar.HOUR,
				calendar.get(Calendar.HOUR) - 1);// 让日期加1
		System.out.println(calendar.get(Calendar.DATE));// 加1之后的日期Top
		System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SS").format(calendar.getTime()));

```