001 package com.valhalla.jbother.jabber.smack;
002
003 import java.util.Calendar;
004 import java.util.TimeZone;
005 import java.util.Date;
006 import java.text.SimpleDateFormat;
007
008 /**
009 * User: luke
010 * Date: 2004-12-30
011 * Time: 23:24:44
012 */
013
014 /**
015 * simple util class that should be able to handle date and time for jabber
016 * based on JEP-0082 (Jabber Date adn Time Profiles)
017 */
018
019 public class DateTimeUtils {
020
021 private static final String fId = "$Id$";
022
023 // format used in JEP. The final 'Z' is for Zulu time
024 public static final String DATETIMEFORMAT = "yyyy-MM-dd'T'hh:mm:ss'Z'";
025
026 public static String getDateTime()
027 {
028 Calendar cal = Calendar.getInstance();
029 SimpleDateFormat dateTimeFormat = new SimpleDateFormat(DATETIMEFORMAT);
030 TimeZone timeZone = cal.getTimeZone();
031
032 return dateTimeFormat.format(new Date(cal.getTimeInMillis()
033 - timeZone.getOffset(cal.getTimeInMillis())));
034 }
035 }