Java Code Examples for org.joda.time.DateTime.get()

The following are Jave code examples for showing how to use get() of the org.joda.time.DateTime class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hyperrail-for-android   File: RouteSearchFragment.java   Source Code and License Vote up 6 votes
@Override
public void onDateTimePicked(DateTime d) {
    searchDateTime = d;

    DateTime now = new DateTime();

    DateTimeFormatter df = DateTimeFormat.forPattern("dd MMMM yyyy");
    DateTimeFormatter tf = DateTimeFormat.forPattern("HH:mm");

    String day = df.print(searchDateTime);
    String time = tf.print(searchDateTime);
    String at = getActivity().getResources().getString(R.string.time_at);

    if (now.get(DateTimeFieldType.year()) == searchDateTime.get(DateTimeFieldType.year())) {
        if (now.get(DateTimeFieldType.dayOfYear()) == searchDateTime.get(DateTimeFieldType.dayOfYear())) {
            day = getActivity().getResources().getString(R.string.time_today);
        } else  //noinspection RedundantCast
            if (now.get(DateTimeFieldType.dayOfYear()) + 1 == (int) searchDateTime.get(DateTimeFieldType.dayOfYear())) {
                day = getActivity().getResources().getString(R.string.time_tomorrow);
            }
    }
    vDatetime.setText(day + " " + at + " " + time);
}
 
Example 2
Project: unitimes   File: QueryLog.java   Source Code and License Vote up 5 votes
public String axe(DateTime now) {
	SimpleDateFormat format = new SimpleDateFormat(iAxeFormat, Localization.getJavaLocale());
	DateTime dt = getFirst(now);
	int i = 0;
	StringBuffer ret = new StringBuffer();
	while (dt != null) {
		if (i > 0) ret.append("|");
		if ((dt.get(iAxeType) % iAxeMod) == iAxeValue)
			ret.append(format.format(dt.getMillis()));
		i++;
		dt = next(dt, now);
	}
	return ret.toString();
}