Java Code Examples for java.util.Calendar#toString()

The following examples show how to use java.util.Calendar#toString() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * 4847186: BuddhistCalendar: toString() returns Gregorian year
 */
static void testToString() {
    Calendar cal = getBuddhistCalendar();
    int year = cal.get(YEAR);
    String s = cal.toString();
    String y = s.replaceAll(".+,YEAR=(\\d+),.+", "$1");
    if (Integer.parseInt(y) != year) {
        throw new RuntimeException("toString(): wrong year value: got " + y
                                   + ", expected " + year);
    }
}
 
Example 2
/**
 * 4847186: BuddhistCalendar: toString() returns Gregorian year
 */
static void testToString() {
    Calendar cal = getBuddhistCalendar();
    int year = cal.get(YEAR);
    String s = cal.toString();
    String y = s.replaceAll(".+,YEAR=(\\d+),.+", "$1");
    if (Integer.parseInt(y) != year) {
        throw new RuntimeException("toString(): wrong year value: got " + y
                                   + ", expected " + year);
    }
}
 
Example 3
/**
 * 4847186: BuddhistCalendar: toString() returns Gregorian year
 */
static void testToString() {
    Calendar cal = getBuddhistCalendar();
    int year = cal.get(YEAR);
    String s = cal.toString();
    String y = s.replaceAll(".+,YEAR=(\\d+),.+", "$1");
    if (Integer.parseInt(y) != year) {
        throw new RuntimeException("toString(): wrong year value: got " + y
                                   + ", expected " + year);
    }
}
 
Example 4
/**
 * 4847186: BuddhistCalendar: toString() returns Gregorian year
 */
static void testToString() {
    Calendar cal = getBuddhistCalendar();
    int year = cal.get(YEAR);
    String s = cal.toString();
    String y = s.replaceAll(".+,YEAR=(\\d+),.+", "$1");
    if (Integer.parseInt(y) != year) {
        throw new RuntimeException("toString(): wrong year value: got " + y
                                   + ", expected " + year);
    }
}
 
Example 5
/**
 * 4847186: BuddhistCalendar: toString() returns Gregorian year
 */
static void testToString() {
    Calendar cal = getBuddhistCalendar();
    int year = cal.get(YEAR);
    String s = cal.toString();
    String y = s.replaceAll(".+,YEAR=(\\d+),.+", "$1");
    if (Integer.parseInt(y) != year) {
        throw new RuntimeException("toString(): wrong year value: got " + y
                                   + ", expected " + year);
    }
}
 
Example 6
Source Project: RipplePower   File: DateUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 返回今天的中文日期
 * 
 * @param Cal
 * @return
 */
public static String toDayOfWeekName(Calendar cal) {
	int dayofweek = 0;
	String tmp = cal.toString();
	tmp = tmp.substring(tmp.indexOf("DAY_OF_WEEK=") + 12, tmp.indexOf("DAY_OF_WEEK=") + 13);
	dayofweek = Integer.parseInt(tmp);
	String dayName = "";
	switch (dayofweek) {
	case 2:
		dayName = "星期一";
		break;
	case 3:
		dayName = "星期二";
		break;
	case 4:
		dayName = "星期三";
		break;
	case 5:
		dayName = "星期四";
		break;
	case 6:
		dayName = "星期五";
		break;
	case 7:
		dayName = "星期六";
		break;
	case 1:
		dayName = "星期天";
		break;
	}
	return dayName;
}