Example usage for org.joda.time DateTime now

List of usage examples for org.joda.time DateTime now

Introduction

In this page you can find the example usage for org.joda.time DateTime now.

Prototype

public static DateTime now() 

Source Link

Document

Obtains a DateTime set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:com.cryart.sabbathschool.viewmodel.SSReadingViewModel.java

License:Open Source License

private void loadLessonInfo() {
    ssLessonLoadingVisibility.set(View.VISIBLE);
    ssLessonEmptyStateVisibility.set(View.INVISIBLE);
    ssLessonErrorStateVisibility.set(View.INVISIBLE);
    ssLessonCoordinatorVisibility.set(View.INVISIBLE);

    mDatabase.child(SSConstants.SS_FIREBASE_LESSON_INFO_DATABASE).child(ssLessonIndex)
            .addValueEventListener(new ValueEventListener() {
                @Override//from w w w  . ja v a2  s  .c o  m
                public void onDataChange(DataSnapshot dataSnapshot) {
                    if (dataSnapshot != null) {
                        ssLessonInfo = dataSnapshot.getValue(SSLessonInfo.class);
                        dataListener.onLessonInfoChanged(ssLessonInfo);

                        if (ssLessonInfo != null && ssLessonInfo.days.size() > 0) {
                            DateTime today = DateTime.now().withTimeAtStartOfDay();
                            int idx = 0;

                            for (SSDay ssDay : ssLessonInfo.days) {
                                DateTime startDate = DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT)
                                        .parseDateTime(ssDay.date).withTimeAtStartOfDay();

                                if (startDate.isEqual(today)) {
                                    ssReadPosition.set(idx);
                                    break;
                                }
                                idx++;
                            }
                        }

                        ssLessonCoordinatorVisibility.set(View.VISIBLE);
                        ssLessonLoadingVisibility.set(View.INVISIBLE);
                        ssLessonEmptyStateVisibility.set(View.INVISIBLE);
                        ssLessonErrorStateVisibility.set(View.INVISIBLE);

                        loadRead();
                    } else {
                        ssLessonEmptyStateVisibility.set(View.VISIBLE);
                        ssLessonErrorStateVisibility.set(View.INVISIBLE);
                        ssLessonLoadingVisibility.set(View.INVISIBLE);
                        ssLessonCoordinatorVisibility.set(View.INVISIBLE);
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    ssLessonErrorStateVisibility.set(View.VISIBLE);
                    ssLessonLoadingVisibility.set(View.INVISIBLE);
                    ssLessonEmptyStateVisibility.set(View.INVISIBLE);
                    ssLessonCoordinatorVisibility.set(View.INVISIBLE);
                }
            });
}

From source file:com.dhr.security.LicenseValidation.java

License:Open Source License

public Boolean isInvalidLicense() {
    String encryptedMessage = (String) patientAdmissionFinder.findEncryptedMessage().get("EncryptedMessage");
    return isInvalidLicense(encryptedMessage, DateTime.now());
}

From source file:com.digi.android.wva.fragments.ChartFragment.java

License:Mozilla Public License

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Don't recreate fragment if activity gets recreated -- just hold
    // onto the existing instance.
    // This is to ensure that the chart remains in existence.
    setRetainInstance(true);//  www.ja va2 s  .co  m

    startTime = DateTime.now().getMillis();
    // endTime is 15 minutes after startTime
    endTime = startTime + TIMESPAN;

    buildGraphPieces();
    clearDataset();

    app = (WvaApplication) getActivity().getApplication();
}

From source file:com.digi.android.wva.model.LogEvent.java

License:Mozilla Public License

/**
 * Create a new LogEvent.//from ww  w  . j a v a2 s.co  m
 *
 * <p>If the timestamp passed in is null, the current time will be used.</p>
 * @param message message of the event
 * @param timestamp timestamp of the event
 * @param alarm true if the event is to record that an alarm went off
 */
public LogEvent(String message, String timestamp, boolean alarm) {
    if (TextUtils.isEmpty(timestamp)) {
        timestamp = ISODateTimeFormat.dateTimeNoMillis().print(DateTime.now());
    }
    this.message = message;
    this.timestamp = timestamp;
    isAlarm = alarm;
}

From source file:com.digi.android.wva.model.VehicleData.java

License:Mozilla Public License

/**
 * Create a new piece of vehicle data/*www. j a  v a  2s .  c om*/
 * @param name endpoint name
 * @param value data value
 * @param timestamp timestamp of data --- if null, the current time will be used
 */
public VehicleData(String name, double value, DateTime timestamp) {
    if (name == null)
        throw new NullPointerException("Can't create VehicleData with null name!");
    this.name = name;
    this.value = value;
    if (timestamp == null)
        timestamp = DateTime.now();
    this.timestamp = timestamp;
}

From source file:com.digitald4.iis.model.License.java

License:Open Source License

public boolean isExpired() {
    return getExpirationDate() != null && showExp() && getExpirationDate().before(DateTime.now().toDate());
}

From source file:com.digitald4.iis.model.License.java

License:Open Source License

public boolean isWarning() {
    return getExpirationDate() != null && showExp()
            && getExpirationDate().after(DateTime.now().minusDays(1).toDate())
            && getExpirationDate().before(DateTime.now().plusDays(30).toDate());
}

From source file:com.digitald4.iis.model.License.java

License:Open Source License

public static List<License> getAlarming(EntityManager entityManager) {
    DateTime window = DateTime.now().plusDays(30);
    window = window.minusMillis(window.getMillisOfDay());
    List<License> alarming = new ArrayList<License>();
    for (License license : getCollection(License.class, entityManager,
            "SELECT o FROM License o WHERE o.EXPIRATION_DATE <= ?1", window.toDate())) {
        if ((license.isExpired() || license.isWarning())
                && license.getNurse().getStatus() == GenData.NURSE_STATUS_ACTIVE.get(entityManager)) {
            alarming.add(license);/*from w w w  . ja v a2 s .c o m*/
        }
    }
    return alarming;
}

From source file:com.digitald4.iis.model.Nurse.java

License:Open Source License

public Nurse(EntityManager entityManager) {
    super(entityManager);
    try {//from w  w w  .  ja  va  2s  . co  m
        setStatus(GenData.NURSE_STATUS_PENDING.get(entityManager));
        setRegDate(DateTime.now().toDate());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.digitald4.iis.servlet.DashboardServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    try {/*w  w w .java2  s. c  om*/
        if (!checkLoginAutoRedirect(request, response))
            return;
        EntityManager entityManager = getEntityManager();
        for (GenData gd : GenData.values()) {
            gd.get(entityManager);
        }
        String action = request.getParameter("action");
        if (action != null && action.equalsIgnoreCase("cal")) {
            processCalendarRequest(request, response);
            return;
        }
        PendingAssServlet.setupTable(entityManager, request);
        PendingIntakeServlet.setupTable(entityManager, request);
        PendingReviewServlet.setupTable(entityManager, request);
        PendingPaymentServlet.setupTable(entityManager, request);
        BillableServlet.setupTable(entityManager, request);
        UnpaidInvoicesServlet.setupTable(request);
        LicenseAlertServlet.setupTable(entityManager, request);
        UnconfirmedAppsServlet.setupTable(request);
        request.setAttribute("upComingUnconfirmed", Appointment.getUpComingUnconfirmed(entityManager));
        DateTime now = DateTime.now();
        request.setAttribute("calendar",
                getCalendar(getEntityManager(), now.getYear(), now.getMonthOfYear()).getOutput());
        getLayoutPage(request, "/WEB-INF/jsp/dashboard.jsp").forward(request, response);
    } catch (Exception e) {
        throw new ServletException(e);
    }
}