/**
* Determines what year a transaction belongs to. If the given <code>day</code> of the given <code>month</code> for the current year is in the future the transaction is probably from last year.
* @param month The month, where January is 1.
* @param day The day of the month, starting from 1.
* @return An ISO 8601 formatted date.
*/
public static String getTransactionDate(int month,int day){
month--;
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
int currentYear=cal.get(Calendar.YEAR);
cal.set(currentYear,month,day,0,0);
if (cal.getTime().after(Calendar.getInstance().getTime())) {
cal.add(Calendar.YEAR,-1);
}
return sdf.format(cal.getTime());
}

Example 9

From project android_packages_apps_Nfc, under directory /src/com/android/nfc/handover/.

/**
* Returns a qualifier that should be used if the plugin's version contains the word "qualifier" as qualifier. <p> <p> The context qualifier can explizitly set by using the ant4eclipse.contextQualifier System property. Note that this is intended mainly for testing, since otherwise you can specify a qualifier in the build.properties
*/
public static final String getResolvedContextQualifier(){
if (CONTEXT_QUALIFIER == null) {
CONTEXT_QUALIFIER=System.getProperty(CONTEXT_QUALIFIER_PROPERTY);
if (CONTEXT_QUALIFIER == null) {
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyyMMddHHmm");
CONTEXT_QUALIFIER=simpleDateFormat.format(new Date());
}
}
return CONTEXT_QUALIFIER;
}

Example 21

From project any23, under directory /core/src/main/java/org/apache/any23/rdf/.

/**
* Whenever a user in the channel types a message, it needs to result in the history being updated with the nickname of the user originating the message and the message itself. We keep a history list of a given maximum size just for general principles. This history list contains the local time at which the message was recived, the nickname of the user who originated the message and the message itself. We send a change notification to all observers indicating that the history has changed when we modify it.
*/
private void addHistoryItem(String nickname,String message){
if (mHistory.size() == HISTORY_MAX) {
mHistory.remove(0);
}
DateFormat dateFormat=new SimpleDateFormat("HH:mm");
Date date=new Date();
mHistory.add("[" + dateFormat.format(date) + "] ("+ nickname+ ") "+ message);
notifyObservers(HISTORY_CHANGED_EVENT);
}

Example 41

From project almira-sample, under directory /almira-sample-webapp/src/main/java/almira/sample/web/.