显示从今天起的100天、从你出生之日起的100天和从你出生之日起的10 000天。我已经做了所有这些,但是我想再进一步一点,我希望用户能够输入从今天起他/她希望知道的日期(如果这有意义的话...)的天数。这里的代码im工作部分看起来像:
public class calendarProjectTest
{
public static void main(String[] args)
{ GregorianCalendar cal = new GregorianCalendar(); //declare today s date
GregorianCalendar myBirthday = new
GregorianCalendar(1990, GregorianCalendar.JUNE, 9); //declare my birthday
System.out.println("Please enter a number greater than 0:");
Scanner keyboard = new Scanner(System.in);
String number = keyboard.next();
int value = number;
cal.add(GregorianCalendar.DAY_OF_MONTH, number);
I m using Bluej and it says, "incompatible types - found java.lang.String but expected int" I m at a loss. i don t have any idea what to do. any advise would be great. and yes, i know there are no end brackets.