怎么取得日语的星期几
请教:我现在有个字符串的日期"2012/03/03",我需要获得这天是日语的星期几?该怎么弄
[解决办法]
import java.util.Calendar;
import java.util.Date;
public class TheDayOfMonth {
/**
* @param args
*/
public static void main(String[] args) {
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
Date t = new Date("2012/03/03");
Calendar cl = Calendar.getInstance();
cl.setTime(t);
int a = cl.get(Calendar.DAY_OF_WEEK)-1;
if(a<0)
System.out.println(weekDays[0]);
else
System.out.println(weekDays[a]);
}
}
[解决办法]
String s="2012/03/03";
DateFormat df=new SimpleDateFormat("yyyy/MM/dd");
Date date=df.parse(s);
Calendar c=Calendar.getInstance(Locale.JAPANESE);
c.setTime(date);
System.out.println(c.get(Calendar.DAY_OF_WEEK));