Search in sources :

Example 86 with ParseException

use of java.text.ParseException in project Openfire by igniterealtime.

the class SimpleSession method contactSubscribed.

//	private Request prepareNotifyRequest(Dialog dialog, SimplePresence simplePresence) throws ParseException {
//		Request request = prepareNotifyRequest(dialog);
//		request.setContent(simplePresence.toXML(), headerFactory.createContentTypeHeader("application", "pidf+xml"));
//
//		return request;
//	}
public void contactSubscribed(String targetSipAddress) {
    try {
        //			Roster     roster     = getTransport().getRosterManager().getRoster(getJID().getNode());
        JID contactJID = getTransport().convertIDToJID(targetSipAddress);
        //            RosterItem item       = roster.getRosterItem(contactJID);
        Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed:  Preparing presence packet...");
        Presence presence = new Presence();
        presence.setFrom(contactJID);
        presence.setTo(getJID());
        presence.setType(Presence.Type.subscribed);
        getTransport().sendPacket(presence);
        Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed:  Presence packet sent ==> \n" + presence.toXML());
    //			Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed:  Synchronizing SIP user roster...");
    //			String rosteruserid = ((SimpleTransport) transport).convertJIDToID(item.getJid());
    //			if (myRoster.getEntry(rosteruserid) == null) {
    //				SimpleBuddy simpleRosterItem = new SimpleBuddy(rosteruserid, item.getNickname(), 1L);
    //				myRoster.addEntry(rosteruserid, simpleRosterItem);
    //			}
    //			Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed:  Finished synchronizing SIP user roster.");
    //			syncContactGroups(contact, item.getGroups());
    } catch (Exception e) {
        Log.debug("SimpleSession(" + jid.getNode() + ").contactSubscribed:  Exception occured when adding pending contact " + targetSipAddress, e);
    //			JID contactJID = getTransport().convertIDToJID(targetSipAddress);
    }
}
Also used : JID(org.xmpp.packet.JID) Presence(org.xmpp.packet.Presence) InvalidArgumentException(javax.sip.InvalidArgumentException) ParseException(java.text.ParseException) NotFoundException(org.jivesoftware.util.NotFoundException) TooManyListenersException(java.util.TooManyListenersException) SipException(javax.sip.SipException) UserNotFoundException(org.jivesoftware.openfire.user.UserNotFoundException)

Example 87 with ParseException

use of java.text.ParseException in project Smack by igniterealtime.

the class TranscriptsProvider method parseAgents.

private List<Transcripts.AgentDetail> parseAgents(XmlPullParser parser) throws IOException, XmlPullParserException {
    List<Transcripts.AgentDetail> agents = new ArrayList<Transcripts.AgentDetail>();
    String agentJID = null;
    Date joinTime = null;
    Date leftTime = null;
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("agentJID")) {
                agentJID = parser.nextText();
            } else if (parser.getName().equals("joinTime")) {
                try {
                    synchronized (UTC_FORMAT) {
                        joinTime = UTC_FORMAT.parse(parser.nextText());
                    }
                } catch (ParseException e) {
                }
            } else if (parser.getName().equals("leftTime")) {
                try {
                    synchronized (UTC_FORMAT) {
                        leftTime = UTC_FORMAT.parse(parser.nextText());
                    }
                } catch (ParseException e) {
                }
            } else if (parser.getName().equals("agent")) {
                agentJID = null;
                joinTime = null;
                leftTime = null;
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("agents")) {
                done = true;
            } else if (parser.getName().equals("agent")) {
                agents.add(new Transcripts.AgentDetail(agentJID, joinTime, leftTime));
            }
        }
    }
    return agents;
}
Also used : ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) Date(java.util.Date)

Example 88 with ParseException

use of java.text.ParseException in project ZhihuDailyPurify by izzyleung.

the class DateHeaderAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(HeaderViewHolder viewHolder, int position) {
    Calendar calendar = Calendar.getInstance();
    try {
        calendar.setTime(Constants.Dates.simpleDateFormat.parse(newsList.get(position).getDate()));
        calendar.add(Calendar.DAY_OF_YEAR, -1);
    } catch (ParseException ignored) {
    }
    viewHolder.title.setText(dateFormat.format(calendar.getTime()));
}
Also used : Calendar(java.util.Calendar) ParseException(java.text.ParseException)

Example 89 with ParseException

use of java.text.ParseException in project ZhihuDailyPurify by izzyleung.

the class SingleDayNewsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getIntent().getExtras();
    Fragment newFragment = new NewsListFragment();
    String dateString = bundle.getString(Constants.BundleKeys.DATE);
    Calendar calendar = Calendar.getInstance();
    try {
        Date date = Constants.Dates.simpleDateFormat.parse(dateString);
        calendar.setTime(date);
        calendar.add(Calendar.DAY_OF_YEAR, -1);
    } catch (ParseException ignored) {
    }
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(DateFormat.getDateInstance().format(calendar.getTime()));
    bundle.putString(Constants.BundleKeys.DATE, dateString);
    bundle.putBoolean(Constants.BundleKeys.IS_FIRST_PAGE, isSameDay(calendar, Calendar.getInstance()));
    bundle.putBoolean(Constants.BundleKeys.IS_SINGLE, true);
    newFragment.setArguments(bundle);
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_frame, newFragment).commit();
}
Also used : Bundle(android.os.Bundle) Calendar(java.util.Calendar) ParseException(java.text.ParseException) NewsListFragment(io.github.izzyleung.zhihudailypurify.ui.fragment.NewsListFragment) Fragment(android.support.v4.app.Fragment) Date(java.util.Date) NewsListFragment(io.github.izzyleung.zhihudailypurify.ui.fragment.NewsListFragment)

Example 90 with ParseException

use of java.text.ParseException in project Openfire by igniterealtime.

the class IQQueryHandler method retrieveMessages.

/**
	 * Retrieve messages matching query request from server archive
	 * @param queryRequest
	 * @return
	 */
private Collection<ArchivedMessage> retrieveMessages(QueryRequest queryRequest) {
    String withField = null;
    String startField = null;
    String endField = null;
    DataForm dataForm = queryRequest.getDataForm();
    if (dataForm != null) {
        if (dataForm.getField("with") != null) {
            withField = dataForm.getField("with").getFirstValue();
        }
        if (dataForm.getField("start") != null) {
            startField = dataForm.getField("start").getFirstValue();
        }
        if (dataForm.getField("end") != null) {
            endField = dataForm.getField("end").getFirstValue();
        }
    }
    Date startDate = null;
    Date endDate = null;
    try {
        if (startField != null) {
            startDate = xmppDateTimeFormat.parseString(startField);
        }
        if (endField != null) {
            endDate = xmppDateTimeFormat.parseString(endField);
        }
    } catch (ParseException e) {
        Log.error("Error parsing query date filters.", e);
    }
    return getPersistenceManager(queryRequest.getArchive()).findMessages(startDate, endDate, queryRequest.getArchive().toBareJID(), withField, queryRequest.getResultSet());
}
Also used : DataForm(org.xmpp.forms.DataForm) ParseException(java.text.ParseException) Date(java.util.Date)

Aggregations

ParseException (java.text.ParseException)1141 Date (java.util.Date)435 SimpleDateFormat (java.text.SimpleDateFormat)387 IOException (java.io.IOException)118 DateFormat (java.text.DateFormat)117 Calendar (java.util.Calendar)104 ArrayList (java.util.ArrayList)98 Test (org.junit.Test)58 HashMap (java.util.HashMap)45 Matcher (java.util.regex.Matcher)39 File (java.io.File)38 GregorianCalendar (java.util.GregorianCalendar)34 Map (java.util.Map)28 BigDecimal (java.math.BigDecimal)23 Timestamp (java.sql.Timestamp)21 List (java.util.List)21 Locale (java.util.Locale)20 SipException (javax.sip.SipException)20 InputStream (java.io.InputStream)19 TimeZone (java.util.TimeZone)19