I want to set the fields of a given source date to a given target date using this method.
private static void setFields(final Date source,
final Date target,
final int ... fields)
{
final Calendar sourceCalendar = Calendar.getInstance();
sourceCalendar.setTime(source);
final Calendar targetCalendar = Calendar.getInstance();
targetCalendar.setTime(target);
for(int field : fields)
targetCalendar.set(field, sourceCalendar.get(field));
}
The minute of the target Date is not set.
How am I suppose to set it if I don’t want to break the reference by using.
target = targetCalendar.getTime();
To change the
targetdate to the value in thetargetCalendar, use:Assuming that’s what you were asking, your question was a little unclear.