0
System.out.println(
  String.format(
     "You are %s weeks, and %s days pregnant", weeks , days ));
4

3 に答える 3

2

2 つの日付の日数差を探している場合 -

public int daysBetween(Date d1, Date d2){
 return (int)( (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24));
 }

週 -

public int weeksBetween(Date d1, Date d2){
 return (int)( (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24 * 7));
 }
于 2012-10-29T06:17:48.457 に答える
0

java.util.Calendarを使用する

t.get(Calendar.DAY_OF_MONTH)     // --- int value of the day of the month (1-31)



t.get(Calendar.DAY_OF_WEEK)      // --- int value of the day of the week (0-6)
于 2012-10-29T06:18:53.683 に答える
0

このようにしてください

int num ; // no. of days
int weeks ; // no of weeks
//initialise num 
weeks = num/7;
days = num % 7;
System.format("no of weeks"+weeks+"no of days"+days); 
于 2012-10-29T06:21:04.663 に答える