Package org.jivesoftware.smack.util

Source Code of org.jivesoftware.smack.util.DateTimeUtils

package org.jivesoftware.smack.util;

import java.util.Calendar;
import java.util.TimeZone;
import java.util.Date;
import java.text.SimpleDateFormat;

/**
* User: luke
* Date: 2004-12-30
* Time: 23:24:44
*/

/**
* simple util class that should be able to handle date and time for jabber
* based on JEP-0082 (Jabber Date adn Time Profiles)
*/

public class DateTimeUtils {

  // format used in JEP. The final 'Z' is for Zulu time
  public static final String DATETIMEFORMAT = "yyyy-MM-dd'T'hh:mm:ss'Z'";

  public static String getDateTime()
  {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat dateTimeFormat = new SimpleDateFormat(DATETIMEFORMAT);
    TimeZone timeZone = cal.getTimeZone();

    return dateTimeFormat.format(new Date(cal.getTimeInMillis()
        - timeZone.getOffset(cal.getTimeInMillis())));
  }
}
TOP

Related Classes of org.jivesoftware.smack.util.DateTimeUtils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.