Search code examples
javagwtgxt

getformat for showing week


How can I set DateTimeFormat to show something like this: "wed.-sun." "mon.-sun." "mon.-sun." "mon.-sun." "mon.-tue"

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");
}

Solution

  • The below code prints

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

    So

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