Example usage for org.joda.time DateTime getHourOfDay

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

Introduction

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

Prototype

public int getHourOfDay() 

Source Link

Document

Get the hour of day field value.

Usage

From source file:loci.formats.in.MetamorphReader.java

License:Open Source License

/** Converts a time value in milliseconds into a human-readable string. */
public static String decodeTime(int millis) {
    DateTime tm = new DateTime(millis, DateTimeZone.UTC);
    String hours = intFormat(tm.getHourOfDay(), 2);
    String minutes = intFormat(tm.getMinuteOfHour(), 2);
    String seconds = intFormat(tm.getSecondOfMinute(), 2);
    String ms = intFormat(tm.getMillisOfSecond(), 3);

    return hours + ":" + minutes + ":" + seconds + ":" + ms;
}

From source file:lucee.commons.date.JodaDateTimeUtil.java

License:Open Source License

@Override
public String toString(lucee.runtime.type.dt.DateTime date, TimeZone tz) {
    //return jreUtil.toString(date, tz);
    /*DateTime dt = new DateTime(date.getTime(),getDateTimeZone(tz));
    return "{ts '"+dt.getYear()+//from  w w  w .j a va 2 s. co m
     "-"+dt.getMonthOfYear()+
     "-"+dt.getDayOfMonth()+
     " "+dt.getHourOfDay()+
     ":"+dt.getMinuteOfHour()+
     ":"+dt.getSecondOfMinute()+"'}";*/

    StringBuilder sb = new StringBuilder();
    DateTime dt = new DateTime(date.getTime(), getDateTimeZone(tz));
    sb.append("{ts '");
    jreUtil.toString(sb, dt.getYear(), 4);
    sb.append("-");
    jreUtil.toString(sb, dt.getMonthOfYear(), 2);
    sb.append("-");
    jreUtil.toString(sb, dt.getDayOfMonth(), 2);
    sb.append(" ");
    jreUtil.toString(sb, dt.getHourOfDay(), 2);
    sb.append(":");
    jreUtil.toString(sb, dt.getMinuteOfHour(), 2);
    sb.append(":");
    jreUtil.toString(sb, dt.getSecondOfMinute(), 2);
    sb.append("'}");

    return sb.toString();
}

From source file:models.MailTransaction.java

License:Apache License

/**
 * @return the Timestamp as String in the Format "dd.MM.yyyy hh:mm"
 *///ww w  .  ja  v  a  2s  .c  o  m
public String getTsAsString() {
    DateTime dt = new DateTime(this.ts);
    String day = "";
    String mon = "";
    String hou = "";
    String min = "";

    // add a leading "0" if the value is under ten
    if (dt.getDayOfMonth() < 10) {
        day += "0";
    }
    day += String.valueOf(dt.getDayOfMonth());

    if (dt.getMonthOfYear() < 10) {
        mon += "0";
    }
    mon += String.valueOf(dt.getMonthOfYear());

    if (dt.getHourOfDay() < 10) {
        hou += "0";
    }
    hou += String.valueOf(dt.getHourOfDay());

    if (dt.getMinuteOfHour() < 10) {
        min += "0";
    }
    min += String.valueOf(dt.getMinuteOfHour());

    return day + "." + mon + "." + dt.getYear() + " " + hou + ":" + min;
}

From source file:models.MBox.java

License:Apache License

/**
 * @return the timestamp as string in the format "yyyy-MM-dd hh:mm" <br/>
 *         if its 0, then also 0 is returned
 *//*w  ww .  ja va 2 s  .c o m*/
@JsonIgnore
public String getTSAsStringWithNull() {
    if (this.ts_Active == 0) {
        return "0";
    } else if (this.ts_Active == -1) {
        return "-1";
    } else {
        DateTime dt = new DateTime(this.ts_Active);
        StringBuilder timeString = new StringBuilder();
        // add a leading "0" if the value is under ten
        timeString.append(dt.getYear()).append("-");
        timeString.append(HelperUtils.addZero(dt.getMonthOfYear()));
        timeString.append("-");
        timeString.append(HelperUtils.addZero(dt.getDayOfMonth()));
        timeString.append(" ");
        timeString.append(HelperUtils.addZero(dt.getHourOfDay()));
        timeString.append(":");
        timeString.append(HelperUtils.addZero(dt.getMinuteOfHour()));
        return timeString.toString();
    }

}

From source file:nbm.center.catalog.CatalogXmlFactory.java

License:Apache License

private String makeCatalogTimestampFrom(DateTime today) {
    String catalogTimestamp = "";
    catalogTimestamp += "00" + "/";
    catalogTimestamp += today.getMinuteOfHour() + "/";
    catalogTimestamp += today.getHourOfDay() + "/";
    catalogTimestamp += today.getDayOfMonth() + "/";
    catalogTimestamp += today.getMonthOfYear() + "/";
    catalogTimestamp += today.getYear();
    return catalogTimestamp;
}

From source file:net.marfgamer.jraknet.RakNetLogger.java

License:Open Source License

/**
 * Logs a message if logging is enabled by the <code>RakNet</code> class and
 * the current level is greater than or equal to the current logging level.
 * //from w  ww . j  ava2  s  . co m
 * @param level
 *            the level of the log.
 * @param message
 *            the message to log.
 */
private static final void log(int level, String message) {
    if (RakNet.isLoggingEnabled() && loggerLevel >= level && level < LEVEL_NAMES.length) {
        DateTime loggerDate = new DateTime(System.currentTimeMillis());
        @SuppressWarnings("resource") // Closing the streams would break the
        // console
        PrintStream logStream = (level != LEVEL_ERROR ? System.out : System.err);
        logStream.println("[" + LOGGER_DATE_FORMAT.format(loggerDate.getHourOfDay()) + ":"
                + LOGGER_DATE_FORMAT.format(loggerDate.getMinuteOfHour()) + ":"
                + LOGGER_DATE_FORMAT.format(loggerDate.getSecondOfMinute()) + "] ["
                + LEVEL_NAMES[level].toUpperCase() + "]" + LEVEL_SPACERS[level] + " JRakNet " + message);
    }
}

From source file:net.naijatek.myalumni.modules.admin.presentation.action.MaintainSystemModuleAction.java

License:Open Source License

/**
 * //from ww  w.j  a  va2s. c o  m
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception
 */
public ActionForward databaseBackup(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    if (!adminSecurityCheck(request)) {
        return mapping.findForward(BaseConstants.FWD_ADMIN_LOGIN);
    }
    ActionMessages msgs = new ActionMessages();
    DateTime dtime = new DateTime(new Date());
    String dateStr = dtime.getMonthOfYear() + "_" + dtime.getDayOfMonth() + "_" + dtime.getYear() + "_"
            + dtime.getHourOfDay() + "_" + dtime.getMinuteOfHour() + "_" + dtime.getSecondOfMinute();

    try {
        sysService.systemDatabaseBackup(getSysProp().getValue("BACKUP.FILEPATH") + dateStr + ".sql");
    } catch (MyAlumniBaseException ex) {
        msgs.add(BaseConstants.ERROR_KEY, new ActionMessage(ex.getMessage()));
        saveMessages(request, msgs);
        return mapping.getInputForward();
    }

    msgs.add(BaseConstants.INFO_KEY, new ActionMessage("message.backupsuccessful", dateStr + ".sql"));
    saveMessages(request, msgs);

    listDatabaseBackupHelper(request);
    return mapping.findForward(BaseConstants.FWD_SUCCESS);
}

From source file:net.naonedbus.manager.impl.HoraireManager.java

License:Open Source License

/**
 * Rcuprer les horaires d'un arrt./* ww  w .j ava2s . co m*/
 * 
 * @throws IOException
 */
public List<Horaire> getSchedules(final ContentResolver contentResolver, final Arret arret,
        final DateMidnight date, final DateTime after) throws IOException {
    // Le cache ne doit stocker que les horaires du jour et du lendemain.

    final DateMidnight cacheLimit = new DateMidnight().plusDays(DAYS_IN_CACHE);
    final DateMidnight today = new DateMidnight();
    final DateTime now = new DateTime();
    List<Horaire> horaires;

    if (date.isBefore(cacheLimit)) {

        final ScheduleToken todayToken = new ScheduleToken(date.getMillis(), arret.getId());

        // Partie atomique
        synchronized (mDatabaseLock) {

            if (!isInDB(contentResolver, todayToken)) {
                // Charger les horaires depuis le web et les stocker en base

                if (date.isEqual(today) && now.getHourOfDay() < END_OF_TRIP_HOURS) {
                    // Charger la veille si besoin (pour les horaires aprs
                    // minuit)
                    final ScheduleToken yesterdayToken = new ScheduleToken(date.minusDays(1).getMillis(),
                            arret.getId());

                    if (isInDB(contentResolver, yesterdayToken)) {
                        horaires = mController.getAllFromWeb(arret, date.minusDays(1));
                        fillDB(contentResolver, yesterdayToken, horaires);
                    }
                }

                horaires = mController.getAllFromWeb(arret, date);
                fillDB(contentResolver, todayToken, horaires);
            }

            // Charger les horaires depuis la base
            final Uri.Builder builder = HoraireProvider.CONTENT_URI.buildUpon();
            builder.path(HoraireProvider.HORAIRE_JOUR_URI_PATH_QUERY);
            builder.appendQueryParameter(HoraireProvider.PARAM_ARRET_ID, String.valueOf(arret.getId()));
            builder.appendQueryParameter(HoraireProvider.PARAM_JOUR, mIso8601Format.format(date.toDate()));
            builder.appendQueryParameter(HoraireProvider.PARAM_INCLUDE_LAST_DAY_TRIP, "true");

            // Eviter l'affichage de doublons
            if (after != null) {
                builder.appendQueryParameter(HoraireProvider.PARAM_AFTER_TIME,
                        mIso8601Format.format(after.toDate()));
            }

            final Cursor cursor = contentResolver.query(builder.build(), null, null, null, null);
            horaires = getFromCursor(cursor);
            cursor.close();
        }

    } else {
        horaires = mController.getAllFromWeb(arret, date);
    }

    return horaires;
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.person.vigilancy.CreateUnavailablePeriod.java

License:Open Source License

private static void sendEmail(Person person, DateTime begin, DateTime end, String justification,
        List<VigilantGroup> groups) {
    for (VigilantGroup group : groups) {
        String bccs = group.getContactEmail();

        String beginDate = begin.getDayOfMonth() + "/" + begin.getMonthOfYear() + "/" + begin.getYear() + " - "
                + String.format("%02d", begin.getHourOfDay()) + ":"
                + String.format("%02d", begin.getMinuteOfHour()) + "h";
        String endDate = end.getDayOfMonth() + "/" + end.getMonthOfYear() + "/" + end.getYear() + " - "
                + String.format("%02d", end.getHourOfDay()) + ":" + String.format("%02d", end.getMinuteOfHour())
                + "h";
        ;/* ww  w  .j  a v  a  2s  .  com*/
        String message = BundleUtil.getString(Bundle.VIGILANCY, "email.convoke.unavailablePeriod",
                new String[] { person.getName(), beginDate, endDate, justification });

        String subject = BundleUtil.getString(Bundle.VIGILANCY, "email.convoke.unavailablePeriod.subject",
                new String[] { group.getName() });

        Sender sender = Bennu.getInstance().getSystemSender();
        new Message(sender, new ConcreteReplyTo(group.getContactEmail()).asCollection(), Collections.EMPTY_LIST,
                subject, message, bccs);
    }
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.scientificCouncil.thesis.ApproveThesisProposal.java

License:Open Source License

private int hasTime(DateTime proposedDiscussed) {
    if (proposedDiscussed.getHourOfDay() == 0 && proposedDiscussed.getMinuteOfHour() == 0) {
        return 0;
    } else {//from   w w w.jav  a2  s. c  om
        return 1;
    }
}