Ages of galaxy bulges and disks from optical and near-infrared colors