Java Code Examples for java.util.Date.getDay()

The following are Jave code examples for showing how to use getDay() of the java.util.Date class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: LiteReader   File: DateUtil.java   View Source Code Vote up 6 votes
public static String getWeekDay(Date date) {
    switch (date.getDay()) {
        case 0:
            return "星期日";
        case 1:
            return "星期一";
        case 2:
            return "星期二";
        case 3:
            return "星期三";
        case 4:
            return "星期四";
        case 5:
            return "星期五";
        case 6:
            return "星期六";
        default:
            return "星期一";
    }
}
 
Example 2
Project: Swface   File: StickyListAdapter.java   View Source Code Vote up 6 votes
private int[] getSectionIndices() {
	ArrayList<Integer> sectionIndices = new ArrayList<Integer>();
	if(mSignLogList.isEmpty()){
		return null;
	}
	Date lastFirstDate = DateUtil.getDateFromLong(mSignLogList.get(0).getTime());
	sectionIndices.add(0);
	int year = lastFirstDate.getYear();
	int month = lastFirstDate.getMonth();
	int date = lastFirstDate.getDay();
	for (int i = 1; i < mSignLogList.size(); i++) {
		Date dateTemp = DateUtil.getDateFromLong(mSignLogList.get(i).getTime());
		int year_temp = dateTemp.getYear();
		int month_temp = dateTemp.getMonth();
		int date_temp = dateTemp.getDay();
		if (year == year_temp && month_temp == month && date_temp == date) {
			continue;
		} else {
			lastFirstDate = DateUtil.getDateFromLong(mSignLogList.get(i).getTime());
			year = lastFirstDate.getYear();
			month = lastFirstDate.getMonth();
			date = lastFirstDate.getDay();
			sectionIndices.add(i);
		}
	}
	int[] sections = new int[sectionIndices.size()];
	for (int i = 0; i < sectionIndices.size(); i++) {
		sections[i] = sectionIndices.get(i);
	}
	return sections;
}
 
Example 3
Project: smile_1.5.0_java7   File: DateFeature.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("deprecation")
public double[] feature(Date date) {
    double[] x = new double[types.length];
    for (int i = 0; i < types.length; i++)
    switch (types[i]) {
        case YEAR:
            x[i] = 1900 + date.getYear();
            break;
        case MONTH:
            x[i] = date.getMonth();
            break;
        case DAY_OF_MONTH:
            x[i] = date.getDate();
            break;
        case DAY_OF_WEEK:
            x[i] = date.getDay();
            break;
        case HOURS:
            x[i] = date.getHours();
            break;
        case MINUTES:
            x[i] = date.getMinutes();
            break;
        case SECONDS:
            x[i] = date.getSeconds();
            break;
        default:
            throw new IllegalStateException("Unknown date feature type: " + types[i]);
    }
    return x;
}
 
Example 4
Project: modern.core.java.repo   File: Travels.java   View Source Code Vote up 5 votes
public void getDateToday(){
    Date date = new Date();
    date.getTime();

    int a = date.getDay();
    System.out.println(a);
}
 
Example 5
Project: letv   File: StringUtils.java   View Source Code Vote up 5 votes
public static int getLocalWeekDay() {
    Calendar.getInstance().get(7);
    Date date = new Date(System.currentTimeMillis());
    if (date.getDay() == 0) {
        return 7;
    }
    return date.getDay();
}
 
Example 6
Project: amap   File: MIP_DateUtil.java   View Source Code Vote up 5 votes
public static String getCurrentWeek()
{
    Date dt = getCurrentDate();
    if (dt != null)
    {
        int day = dt.getDay();
        
        switch (day)
        {
            case 0:
                
                return "星期日";
            case 1:
                
                return "星期一";
            case 2:
                
                return "星期二";
            case 3:
                
                return "星期三";
            case 4:
                
                return "星期四";
            case 5:
                
                return "星期五";
                
            case 6:
                
                return "星期六";
                
            default:
                break;
        }
    }
    return "";
}
 
Example 7
Project: DAFramework   File: TextUtils.java   View Source Code Vote up 5 votes
@SuppressWarnings("deprecation")
public static String getShortTimeText(Long oldTime) {
	Date time = parseDate(oldTime, TimeFormat);
	Date now = new Date();
	String format = "yyyy-MM-dd HH:mm";
	if (time.getYear() == now.getYear()) {
		format = format.substring("yyyy-".length());
		if (time.getMonth() == now.getMonth() && time.getDay() == now.getDay()) {
			format = format.substring("MM-dd ".length());
		}
	}
	return formatDate(time, format);
}
 
Example 8
Project: unitimes   File: PeriodPreferencesWidget.java   View Source Code Vote up 5 votes
@SuppressWarnings("deprecation")
static int weekNumber(int year, int month) {
	Date d = new Date(year - 1900, month - 1, 1);
	while (d.getDay() != CalendarUtil.getStartingDayOfWeek()) d.setDate(d.getDate() - 1);
	int y = d.getYear();
	int week = 0;
	while (d.getYear() == y) { d.setDate(d.getDate() - 7); week += 1; }
	return week;
}
 
Example 9
Project: unitimes   File: SingleDateSelector.java   View Source Code Vote up 5 votes
@SuppressWarnings("deprecation")
static int weekNumber(int year, int month) {
	Date d = new Date(year - 1900, month - 1, 1);
	while (d.getDay() != CalendarUtil.getStartingDayOfWeek()) d.setDate(d.getDate() - 1);
	int y = d.getYear();
	int week = 0;
	while (d.getYear() == y) { d.setDate(d.getDate() - 7); week += 1; }
	return week;
}
 
Example 10
Project: DaUtil   File: TextUtils.java   View Source Code Vote up 5 votes
@SuppressWarnings("deprecation")
public static String getShortTimeText(Long oldTime) {
	Date time = parseDate(oldTime, TimeFormat);
	Date now = new Date();
	String format = "yyyy-MM-dd HH:mm";
	if (time.getYear() == now.getYear()) {
		format = format.substring("yyyy-".length());
		if (time.getMonth() == now.getMonth() && time.getDay() == now.getDay()) {
			format = format.substring("MM-dd ".length());
		}
	}
	return formatDate(time, format);
}
 
Example 11
Project: Programmers   File: Util.java   View Source Code Vote up 5 votes
public static boolean getTimeState(long time) {
    boolean output;

    Date last = new Date(time);
    Date current = new Date(System.currentTimeMillis());

    output = last.getYear() < current.getYear() ||
            last.getMonth() < current.getMonth() ||
            last.getDay() < current.getDay() ||
            last.getHours() < current.getHours() ||
            last.getMinutes() < current.getMinutes();

    return output;
}
 
Example 12
Project: HL4A   File: 时间工具.java   View Source Code Vote up 4 votes
public static Integer 星期(Date $时间) {
		return $时间.getDay();
}
 
Example 13
Project: LucaHome-AndroidApplication   File: CalendarEntryDto.java   View Source Code Vote up 4 votes
public boolean IsToday() {
    Calendar calendar = Calendar.getInstance();
    Date now = calendar.getTime();
    return _begin.getDay() == now.getDay() && _begin.getMonth() == now.getMonth() && _begin.getYear() == now.getYear();
}
 
Example 14
Project: modern.core.java.repo   File: GetDate.java   View Source Code Vote up 3 votes
public void getTodaysDate(){
    Date date = new Date();
    date.getTime();


    int today = date.getDay();
    System.out.println(today);

}