replace code to use primitive int type instead of Calendar