Tuesday

Why is SimpleDateFormat changing given date?

//The upper case Y is "week year". It has 364 or 371 days 
//The lower case y has usual 365 or 366.
//So they give different outputs:
//Locale.forLanguageTag("tr_TR") >> comes with Java 7

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;


public class Test {

    public static void main(String[] args) {
       try {
           String dateString = new java.util.Date().toString();
           System.out.println(dateString);

           SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.forLanguageTag("tr_TR"));
           Date date = format.parse(dateString);
           System.out.println(date.toString());

           SimpleDateFormat format2 = new SimpleDateFormat("EEE MMM dd HH:mm:ss z YYYY", Locale.forLanguageTag("tr_TR"));
           Date date2 = format2.parse(dateString);
           System.out.println(date2.toString());

       } catch (ParseException e) {
           //log
       }
    }
    
}
Output:

Mon May 14 10:31:14 EEST 2018
Mon May 14 10:31:14 EEST 2018
Mon Jan 01 09:31:14 EET 2018

Friday

f:selectItems => adding tooltip

Put pass-through into to the namespace.
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"

You can use passthrough 'title' attribute:
<f:selectItems value="#{values}" pt:title="Your tooltip desc"/>

Execute two methods in action

You can use f:actionListener to execute 2 methods in action:
<a4j:commandbutton action="{method1()}" value="deneme" >                              
   <f:actionlistener binding="#{method2()}"/>
<a4j:commandbutton>

Sort list of strings by using Localization

import java.text.Collator;

List<String> yourValues = ;
Collections.sort(yourValues, Collator.getInstance(Locale.forLanguageTag("your locale ")));

See Collator interface.