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

The following examples show how to use java.util.Calendar#toString() . 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 check out the related API usage on the sidebar.
Example 1
Source File: BuddhistCalendarTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: BuddhistCalendarTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: BuddhistCalendarTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: BuddhistCalendarTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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
Source File: BuddhistCalendarTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 File: DateUtils.java    From RipplePower with 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;
}