1

如何设置 DateTimeFormat 以显示如下内容:“wed.-sun.” “星期一-太阳。” “星期一-太阳。” “星期一-太阳。” “周一至周二”

DateTimeFormat dtfDate = DateTimeFormat.getFormat("dd.MM");

if (rt.detalization.equals("date")) {
    dtfDate = DateTimeFormat.getFormat("dd.MM");
}
if (rt.detalization.equals("week")) {                
    dtfDate = DateTimeFormat.getFormat("EEE.dd-EEE.dd");
    //how can show week from choisen day to sunday like I wrote before
}
if (rt.detalization.equals("month")) {
    dtfDate = DateTimeFormat.getFormat("MMM");
}
4

1 回答 1

0

下面的代码打印

     DateTimeFormat format2 = DateTimeFormat.getFormat("E");
     String format = format2.format(new Date());
     System.out.println(format); //prints "Mon"

所以

if (rt.detalization.equals("week")) {  
       DateTimeFormat format2 = DateTimeFormat.getFormat("E");
    String day= format2.format(dtfDate);              
         System.out.println(day+"-Sun");

}
于 2013-04-01T12:04:03.290 回答