简体   繁体   English

如何使用Java中的Calendar类以不同的字体颜色显示周末?

[英]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. 但是后来我确实使用String函数在JSF页面上尝试了它,但是它确实起作用了。

<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'}">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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