From exponential to finite/fixed-time stability: Applications to optimization