Groovy web console

subscribe to the feed Subscribe
to this
site

dateduration

Published 5 years ago by laloune
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import java.text.SimpleDateFormat;
import groovy.time.TimeCategory;

inputFormat=new SimpleDateFormat('dd.MM.yyyy H:mm');

inputOpen='16.04.2014' + ' ' + '22:45';
inputEnd='17.04.2014'  + ' ' + '03:15';

inputOpenAsDate=inputFormat.parse(inputOpen);
inputEndAsDate=inputFormat.parse(inputEnd);

println inputOpenAsDate;
println inputEndAsDate;

diff=TimeCategory.minus(inputEndAsDate, inputOpenAsDate)
println diff.hours*60 + diff.minutes;