I see you're trying to compensate for the time zone. What happens if you take out the adjustment: "sdf.getTimeZone().getOffset(temp.getTime()"? We had a production app that hummed along happily until daylight savings time came in, and I think we made a date format with no timezone info or a "dumb" default timezone that never adjusted. It was deeply confusing at the time.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi