function s = gmtstr(sec)
% GMTSTR - Geneartes a string of the current time in GMT 
%
% Use as: s = gmtstr(sec) 	% For time string at Unix seconds
%     or: s = gmtstr		% For current time
%
% $Id: gmtstr.m,v 1.3 2004/03/23 00:54:21 mccann Exp $

% Brian Schlining
% 20 Feb 2004

c = java.util.GregorianCalendar(java.util.TimeZone.getTimeZone('GMT'));
if (exist('sec', 'var')) 
	c.setTime(java.util.Date(1000*sec));
else 
	c.setTime(java.util.Date);
end

Y = c.get(c.YEAR);
M = c.get(c.MONTH) + 1;
D = c.get(c.DAY_OF_MONTH);
h = c.get(c.HOUR_OF_DAY);
m = c.get(c.MINUTE);
s = c.get(c.SECOND);

s = sprintf('%04i-%02i-%02iT%02i:%02i:%02iZ', Y, M, D, h, m, s);