简体   繁体   中英

How to display the weekend in different font color using Calendar class in Java?

Currently the font color is same for all the days in the calender, but I want to make weekend in different color.

 Calendar c = Calendar.getInstance(Constants.localeCosnt); 
 int dateValue = c.get(Calendar.DATE);
 setFortnightsOfTheMonth(DateUtils.getFortnightsOfTheMonth(c.getTime(), dateValue));

Seems like you want your output to be colored. Use appropriate text output component you are using. You can do something like this

JTextArea txt = new JTextArea();
Font font = new Font("Verdana", Font.BOLD, 12);
txt.setFont(font);
txt.setForeground(Color.BLUE);

Note you will need to use your own text component output. What I'm doing is just showing a path

Thanks for your answer.

But later I did try it from JSF page using String function and it did work.

<p:column id="hoursWorkedDay1"
    headerText="#{timeAndExpenseManagedController.firstDate}"
    style="background-color:#{timeAndExpenseManagedController.firstDate.substring(0,3)== 'Sat' or
    timeAndExpenseManagedController.firstDate.substring(0,3)== 'Sun'?  
    '#e6f0ff !important' : 'none !important'}">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM