# Date Tage abziehen



## Rj (31. Aug 2004)

Wie kann ich bei einem java.util.Date; 7 tage abziehen ?


----------



## meez (31. Aug 2004)

```
Date d = new Date();

Calendar c = Calendar.getInstance();
c.setTime(d);
c.roll(Calendar.DAY_OF_MONTH,  -7);

d = c.getTime();
```


----------



## Rj (31. Aug 2004)

thx


----------



## foobar (31. Aug 2004)

```
Calendar now = Calendar.getInstance( ); 
SimpleDateFormat formatter = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz"); 
System.out.println("heute >>" + formatter.format(now.getTime( ))); 
now.add(Calendar.DAY_OF_YEAR, - 7);
System.out.println("vor 7 Tagen >>" + formatter.format(now.getTime()));
```


----------

