use of java.text.ParseException in project head by mifos.
the class HomePageController method loadLoanOfficerCustomersHierarchyForSelectedDay.
private void loadLoanOfficerCustomersHierarchyForSelectedDay(Short userId, ModelAndView modelAndView, CustomerSearchFormBean customerSearchFormBean) throws MifosException {
CustomerHierarchyDto hierarchy;
List<String> nearestDates = new ArrayList<String>();
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", personnelServiceFacade.getUserPreferredLocale());
Date selectedDate = new LocalDate().toDateMidnight().toDate();
DateTime nextDate = new DateTime();
for (int i = 0; i < 7; i++) {
nearestDates.add(formatter.format(nextDate.toDate()));
nextDate = nextDate.plusDays(1);
}
if (customerSearchFormBean.getSelectedDateOption() != null) {
try {
selectedDate = formatter.parse(customerSearchFormBean.getSelectedDateOption());
} catch (ParseException e) {
throw new MifosException(e);
}
}
hierarchy = personnelServiceFacade.getLoanOfficerCustomersHierarchyForDay(userId, new DateTime(selectedDate));
modelAndView.addObject("nearestDates", nearestDates);
modelAndView.addObject("hierarchy", hierarchy);
}
use of java.text.ParseException in project head by mifos.
the class BranchReportService method getBranchReportHeaderDTO.
@Override
public BranchReportHeaderDTO getBranchReportHeaderDTO(Integer branchId, String runDate) throws ServiceException {
Short officeId = convertIntegerToShort(branchId);
PersonnelBO branchManager = CollectionUtils.first(personnelBusinessService.getActiveBranchManagersUnderOffice(officeId));
try {
return new BranchReportHeaderDTO(officeBusinessService.getOffice(officeId), branchManager == null ? null : branchManager.getDisplayName(), ReportUtils.parseReportDate(runDate));
} catch (ParseException e) {
throw new ServiceException(e);
}
}
use of java.text.ParseException in project qksms by moezbhatti.
the class DateFormatter method getSummaryTimestamp.
public static String getSummaryTimestamp(Context context, String time) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("H:mm");
Date date;
try {
date = simpleDateFormat.parse(time);
simpleDateFormat = accountFor24HourTime(context, new SimpleDateFormat("H:mm"));
time = simpleDateFormat.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
return time;
}
use of java.text.ParseException in project mavuno by metzlerd.
the class TwitterDocument method initialize.
private void initialize() throws JSONException {
// get json representation of the tweet
JSONObject jobj = new JSONObject(mRawDoc.toString());
// get tweet id
if (jobj.has("id")) {
mTweetId = jobj.getLong("id");
} else {
mTweetId = 0;
}
// get tweet text
if (jobj.has("text")) {
mText = jobj.getString("text");
} else {
mText = "";
}
// get tweet timestamp
if (jobj.has("created_at")) {
try {
mTimestamp = DATE_PARSER.parse(jobj.getString("created_at")).getTime();
} catch (ParseException e) {
mTimestamp = 0L;
}
} else {
mTimestamp = 0L;
}
// is this a retweet?
if (jobj.has("retweeted")) {
mIsRetweet = jobj.getBoolean("retweeted") || (mText != null && mText.toLowerCase().startsWith("rt "));
} else {
mIsRetweet = false;
}
// get user information
if (jobj.has("user")) {
JSONObject userinfo = jobj.getJSONObject("user");
if (userinfo.has("screen_name")) {
mUserScreenName = userinfo.getString("screen_name");
}
if (userinfo.has("location")) {
mUserLocation = userinfo.getString("location");
} else {
mUserLocation = "";
}
}
// get geo information
if (jobj.has("geo")) {
try {
JSONObject geoinfo = jobj.getJSONObject("geo");
if (geoinfo.has("type") && geoinfo.getString("type").equals("Point") && geoinfo.has("coordinates")) {
JSONArray coords = geoinfo.getJSONArray("coordinates");
mUserLongitude = coords.getDouble(0);
mUserLatitude = coords.getDouble(1);
}
} catch (JSONException e) {
mUserLongitude = 0.0;
mUserLatitude = 0.0;
}
}
}
use of java.text.ParseException in project qksms by moezbhatti.
the class NightModeAutoReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean(SettingsFragment.NIGHT_AUTO, false)) {
Calendar calendar = Calendar.getInstance();
// add 5 mins in case receiver is called early
calendar.setTimeInMillis(System.currentTimeMillis() + 300000);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("H:mm");
Calendar day = Calendar.getInstance();
Calendar night = Calendar.getInstance();
try {
day.setTime(simpleDateFormat.parse(prefs.getString(SettingsFragment.DAY_START, "6:00")));
night.setTime(simpleDateFormat.parse(prefs.getString(SettingsFragment.NIGHT_START, "21:00")));
} catch (ParseException e) {
e.printStackTrace();
}
if ((calendar.get(Calendar.HOUR_OF_DAY) > night.get(Calendar.HOUR_OF_DAY)) || (calendar.get(Calendar.HOUR_OF_DAY) == night.get(Calendar.HOUR_OF_DAY) && calendar.get(Calendar.MINUTE) >= night.get(Calendar.MINUTE)) || (calendar.get(Calendar.HOUR_OF_DAY) < day.get(Calendar.HOUR_OF_DAY)) || (calendar.get(Calendar.HOUR_OF_DAY) == day.get(Calendar.HOUR_OF_DAY) && calendar.get(Calendar.MINUTE) <= day.get(Calendar.MINUTE))) {
Log.i(TAG, "Switching to night mode");
prefs.edit().putString(SettingsFragment.BACKGROUND, ThemeManager.Theme.PREF_GREY).apply();
ThemeManager.setTheme(ThemeManager.Theme.DARK);
} else {
Log.i(TAG, "Switching to day mode");
prefs.edit().putString(SettingsFragment.BACKGROUND, ThemeManager.Theme.PREF_OFFWHITE).apply();
ThemeManager.setTheme(ThemeManager.Theme.LIGHT);
}
}
}
Aggregations