This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes add(Calendar.DATE) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

add(Calendar.DATE)

vidhya subramaniam
Ranch Hand

Joined: Jul 14, 2001
Posts: 91
import java.util.Calendar;
import java.util.Properties;
public class datecalc {
public static void main(String args[]){
Calendar rightNow = Calendar.getInstance();
int julianDay = rightNow.get(Calendar.DAY_OF_YEAR);
System.out.println(julianDay);
int day = rightNow.get(Calendar.DATE);

// Create a copy of the rightNow Calendar object
Calendar baseCal = (Calendar)rightNow.clone();
// Subtract 5 days from the date
int i =rightNow.add(Calendar.DATE, -5);
System.out.println(i);

When I do this i get an error on i as incompatible datatypes.
which datatype does add(Calendar.DATE) return?
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

try read the API
Rene


Regards, Rene Larsen
Dropbox Invite
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Please follow up your discussion in the original thread rather than starting a new thread for each related question. Thanks.


"I'm not back." - Bill Harding, Twister
 
GeeCON Prague 2014
 
subject: add(Calendar.DATE)