Example usage for org.joda.time.format DateTimeFormatter print

List of usage examples for org.joda.time.format DateTimeFormatter print

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormatter print.

Prototype

public String print(ReadablePartial partial) 

Source Link

Document

Prints a ReadablePartial to a new String.

Usage

From source file:com.yunguchang.data.ApplicationRepository.java

private void merge(TBusApplyinfoEntity application, TBusApplyinfoEntity applyinfoEntity) {
    DateTime now = DateTime.now();//from ww w  . j a  v  a  2  s .  c o  m
    DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMddHHmmssSSS");
    applyinfoEntity.setUpdatedate(now);
    if (StringUtils.isNotBlank(application.getApplyno())) {
        applyinfoEntity.setApplyno(application.getApplyno());
    } else {
        applyinfoEntity.setApplyno(formatter.print(now));
    }
    applyinfoEntity.setBegintime(application.getBegintime());
    applyinfoEntity.setEndtime(application.getEndtime());
    applyinfoEntity.setCargodes(application.getCargodes());
    applyinfoEntity.setStartpoint(application.getStartpoint());
    applyinfoEntity.setWays(application.getWays());
    applyinfoEntity.setReason(application.getReason());
    applyinfoEntity.setRemark(application.getRemark());
    applyinfoEntity.setIssend(StringUtils.isBlank(application.getIssend()) ? "0" : application.getIssend());
    if (ApplyStatus.APPLY_CANCEL.toStringValue().equals(application.getStatus())) { // ?
        applyinfoEntity.setCanceltype(application.getCanceltype());
        applyinfoEntity.setCancelseason(application.getCancelseason());
    }
    if (application.getUpdateBySync() != null && application.getUpdateBySync()) {
        applyinfoEntity.setUpdateBySync(true);
    } else {
        applyinfoEntity.setUpdateBySync(false);
    }

    TSysUserEntity coordinator = em.find(TSysUserEntity.class, application.getCoordinator().getUserid());
    if (coordinator == null) {
        throw logger.entityNotFound(TSysUserEntity.class, application.getCoordinator().getUserid());
    }
    applyinfoEntity.setCoordinator(coordinator);

    if (application.getPassenger() != null) {
        TBusMainUserInfoEntity passenger = em.find(TBusMainUserInfoEntity.class,
                application.getPassenger().getUuid());

        TSysOrgEntity department;
        if (passenger != null) { // null =>> ?? ? passenger ID
            applyinfoEntity.setPassenger(passenger);
            if (coordinator.getDepartment().getOrgid().startsWith("001")) {
                department = passenger.getSysOrg();
            } else {
                department = coordinator.getDepartment();
            }
        } else {
            department = coordinator.getDepartment();
        }
        applyinfoEntity.setDepartment(department);
        applyinfoEntity.setPeoplenum(application.getPeoplenum());

        TSysOrgEntity fleet = findRightFleetOfCoordinator(coordinator.getUserid());
        applyinfoEntity.setFleet(fleet);
    }

    if (application.getSenduser() != null && application.getSenduser().getUserid() != null) {
        TSysUserEntity sender = em.find(TSysUserEntity.class, application.getSenduser().getUserid());
        if (sender == null) {
            throw logger.entityNotFound(TSysUserEntity.class, application.getSenduser().getUserid());
        }
        applyinfoEntity.setSenduser(sender);
    } else {
        List<TSysUserEntity> senderList = busBusinessRelationRepository
                .getDispatcherOfPassenger(applyinfoEntity.getPassenger().getUuid());
        if (!senderList.isEmpty()) {
            applyinfoEntity.setSenduser(senderList.get(0));
        }
    }
}

From source file:com.ze.client.projecto.database.ProjectoContract.java

License:Apache License

public static String convertDateToDatabaseFormat(DateTime date) {
    if (date != null) {
        DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
        return fmt.print(date);
    } else//from w  w  w  . j  a  v a  2s  . c  o  m
        return "";
}

From source file:common.JsonDateSerializer.java

License:Apache License

@Override
public void serialize(Date date, JsonGenerator jGen, SerializerProvider sProv)
        throws IOException, JsonProcessingException {
    DateTime dt = new DateTime(date);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    jGen.writeString(fmt.print(dt));
}

From source file:controllers.Api.Statistic.java

License:Open Source License

public static Result getAccess() {
    // Variables/*from ww w  .j  av a 2 s . c om*/
    Integer newValue, accessHour, yesterdayHour, index = 0;
    DateTime yesterdayDayTime, accessTime;

    // Yesterday Time Calc
    yesterdayDayTime = (new DateTime()).withZone(DateTimeZone.forID(session("timezone")));
    //yesterdayDayTime = yesterdayDayTime.minusHours(24);
    yesterdayDayTime = yesterdayDayTime.minusHours(23).minusMinutes(yesterdayDayTime.getMinuteOfHour())
            .minusSeconds(yesterdayDayTime.getSecondOfMinute());
    yesterdayHour = yesterdayDayTime.getHourOfDay();

    DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    List<models.Access> accessDay = models.Access.find.where()
            .ge("timestamp", fmt.print(yesterdayDayTime.toDateTime(DateTimeZone.UTC))).order().asc("timestamp")
            .findList();
    Iterator<models.Access> accessDayIterator = accessDay.iterator();

    // 0 Liste initialisieren
    List<Integer> accessDayReturn = Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0);

    // Iterate List
    while (accessDayIterator.hasNext()) {
        models.Access access = accessDayIterator.next();
        // Access Time Calc
        accessTime = access.timestamp;
        accessTime = accessTime.withZone(DateTimeZone.forID(session("timezone")));
        accessHour = accessTime.getHourOfDay();

        // Set value
        if (accessHour == yesterdayHour) {
            index = accessDayReturn.size() - 1;
        } else if (accessHour > yesterdayHour) {
            index = accessHour - yesterdayHour;
        } else if (accessHour < yesterdayHour) {
            index = (24 - (yesterdayHour - accessHour)) % 24;
        }

        newValue = accessDayReturn.get(index) + 1;
        accessDayReturn.set(index, newValue);

    }
    return ok(Json.toJson(accessDayReturn));
}

From source file:csv.CSVCreator.java

/**
 * Converts a duration object to a descriptive string of that object
 *
 * @param interval//w  w  w . j  av a2 s.com
 * @return a descriptive string of the given input
 */
private String convertDurationToString(Interval interval) {
    DateTime start = interval.getStart();
    DateTime end = interval.getEnd();

    DateTimeFormatter df = DateTimeFormat.forPattern("y-MM-dd");

    return df.print(start) + " - " + df.print(end);
}

From source file:csv.CSVCreator.java

/**
 * converts an instant object to a descriptive string
 *
 * @param instant/*from   ww  w  .  j  a va 2s.c o m*/
 * @return a descriptive string of the instant object
 */
private String convertInstantToString(DateTime instant) {
    DateTimeFormatter df = DateTimeFormat.forPattern("y-MM-dd");
    return df.print(instant);
}

From source file:cz.krtinec.birthday.DateFormatter.java

License:Open Source License

public String format(LocalDate date, DateIntegrity integrity) {
    if (date == null) {
        return EMPTY_DATE;
    }/*from  w ww .  j a v  a2s.c o m*/

    DateTimeFormatter format = integrity == DateIntegrity.FULL ? longFormat : shortFormat;

    return format.print(date);
}

From source file:cz.krtinec.birthday.DateFormatter.java

License:Open Source License

/**
 * Format date for edit button./*w  ww.ja  v  a2s .  c om*/
 * @param date
 * @return
 */
public String formatEdit(LocalDate date) {
    if (date == null) {
        return EMPTY_DATE;
    }
    DateTimeFormatter pattern = DateTimeFormat
            .forPattern(ctx.getResources().getStringArray(R.array.long_format_values)[0]);

    return pattern.print(date);
}

From source file:damo.three.ie.util.DateUtils.java

License:Open Source License

/**
 * Convert a date as milliseconds to a string representation
 *
 * @param input Date in milliseconds//from w ww .  ja  v  a 2 s.  c  om
 * @return {@link String}
 */
public static String formatDate(Number input) {
    if (input == null || input.longValue() == WONT_EXPIRE) {
        return "Won't expire";
    } else if (input.longValue() == QUEUED) {
        return "Queued";
    }

    DateTime dateTime = new DateTime(input.longValue());
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.mediumDate();

    return dateTimeFormatter.print(dateTime);
}

From source file:damo.three.ie.util.DateUtils.java

License:Open Source License

/**
 * Convert a date as milliseconds to a string representation
 *
 * @param input DateTime in milliseconds
 * @return {@link String}//from   w  w w .  j av a  2s .  c  o  m
 */
public static String formatDateTime(long input) {
    DateTime dateTime = new DateTime(input);
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.mediumDateTime();
    return dateTimeFormatter.print(dateTime);
}