converting GregorianCaledanr value to String is easy by
using SimpleDateFormat class
but how to convert it into int
------------------------------------
String representation
--------------------------------------------------------------------public static void main(String[] args)throws IOException { int year, month, day; GregorianCalendar cal; SimpleDateFormat sdf; System.out.print("Enter Year: "); year = Integer.parseInt(br.readLine( )); System.out.print("Enter Month:"); month = Integer.parseInt(br.readLine( )); System.out.print("Enter Day: "); day = Integer.parseInt(br.readLine( )); cal = new GregorianCalendar(year, month-1, day); sdf = new SimpleDateFormat("EEEE"); System.out.println("Day Of Week: " + sdf.format(cal.getTime( ))); } }
the problem is asking to display it as int
heres the code i hope you understand this
//sets the expiration date public void setExpDate(GregorianCalendar date) { ........<statement> here } //returns the epiration year public int getExpYear( ) { ......<statement> here } //returns the expriration month public int getExpMonth( ) { .....<statement>Here } //returns the expiration day public int getExpDay( ) { .....<statement> here }
setting the date is easy , displaying the date by String representaion is easy
but how to display it into an INteger value?
the program is asking me to extend a predefined class (LibraryCard class) by adding such methods
for an expiring date of a card
but to display it as int ...
Oh my....