Example usage for org.joda.time DateTimeZone forID

List of usage examples for org.joda.time DateTimeZone forID

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone forID.

Prototype

@FromString
public static DateTimeZone forID(String id) 

Source Link

Document

Gets a time zone instance for the specified time zone id.

Usage

From source file:com.coderoad.automation.common.util.DateUtil.java

License:Open Source License

/**
 * Gets the current time stamp for zone.
 * /*from  ww w .  j  a  v  a2  s.co  m*/
 * @param timeZone the time zone
 * @param pattern the pattern
 * @return the current time stamp for zone
 */
public static String getCurrentTimeStampForZone(String timeZone, String pattern) {

    DateTime startDate = new DateTime(DateTimeZone.forID(timeZone));
    DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern);
    return fmt.print(startDate);
}

From source file:com.coderoad.automation.common.util.DateUtil.java

License:Open Source License

/**
 * Gets the UTC time from local./*from  www .  j av  a 2  s.c  o  m*/
 * 
 * @param localTimeInMillis the local time in millis
 * @param timeZone the time zone
 * @return the UTC time from local
 */
public static long getUTCTimeFromLocal(long localTimeInMillis, String timeZone) {

    long utcTime = 0;
    DateTimeZone dateTimeZone = DateTimeZone.forID(timeZone);
    utcTime = dateTimeZone.convertLocalToUTC(localTimeInMillis, false);
    return utcTime;
}

From source file:com.coderoad.automation.common.util.DateUtil.java

License:Open Source License

/**
 * Convert timezone.//from www  .ja  v  a2 s. co m
 * 
 * @param date the date
 * @param srcTimeZone the src time zone
 * @param destTimeZone the dest time zone
 * @return the date
 */
public static Date convertTimezone(LocalDateTime date, String srcTimeZone, String destTimeZone) {

    DateTime srcDateTime = date.toDateTime(DateTimeZone.forID(srcTimeZone));
    DateTime dstDateTime = srcDateTime.withZone(DateTimeZone.forID(destTimeZone));
    return dstDateTime.toLocalDateTime().toDateTime().toDate();
}

From source file:com.coderoad.automation.core.listener.AutomationListener.java

License:Open Source License

@Override
public void onTestStart(ITestResult arg0) {

    LogUtil.setNoOfSteps(0);/*from  www . j  av a  2  s. c om*/
    LogUtil.setNoOfSections(0);

    LogUtil.commonConsoleLog(new StringBuilder("").toString());
    LogUtil.commonConsoleLog(new StringBuilder("").toString());

    long time = Calendar.getInstance().getTimeInMillis();
    String startTime = DateUtil.formatToZone(time, DateTimeZone.forID("America/Los_Angeles"),
            DateUtil.LARGE_FORMAT);
    String content = "<p style=\"text-decoration:underline;font-weight:bold\">START TIME : " + startTime
            + "</p>";
    logStart = content;
    String methodName = arg0.getMethod().getMethodName();
    LogUtil.commonConsoleLog(new StringBuilder("Started Test " + methodName).toString());
    LogUtil.commonConsoleLog(new StringBuilder("START TIME : " + startTime).toString());
}

From source file:com.coderoad.automation.core.listener.AutomationListener.java

License:Open Source License

/**
 * End log./* w  ww . j  av a 2  s.co  m*/
 * 
 * @param arg0 the arg0
 */
private void endLog(ITestResult arg0) {
    long time = Calendar.getInstance().getTimeInMillis();
    String startTime = DateUtil.formatToZone(time, DateTimeZone.forID("America/Los_Angeles"),
            DateUtil.LARGE_FORMAT);
    String content = "<b style=\"text-decoration:underline\">END TIME : " + startTime + "</b>";
    Reporter.log(logStart + "############" + content);
    String methodName = arg0.getMethod().getMethodName();
    LogUtil.commonEndConsoleLog(new StringBuilder("END TIME : " + startTime + "").toString());
    LogUtil.commonEndConsoleLog(new StringBuilder("Ended Test " + methodName + "").toString());
    LogUtil.commonEndConsoleLog(new StringBuilder("").toString());
    LogUtil.setNoOfSteps(0);
    LogUtil.setNoOfSections(0);
}

From source file:com.court.controller.CollectionSheetFxmlController.java

private java.util.Date getInstallmentDate(java.util.Date lastInstDate) {
    DateTimeZone zone = DateTimeZone.forID("Asia/Colombo");
    DateTime lastInst = new DateTime(new SimpleDateFormat("yyyy-MM-dd").format(lastInstDate), zone);
    DateTime nowDate = lastInst.plusMonths(1);
    return nowDate.toDate();
}

From source file:com.court.controller.CollectionSheetFxmlController.java

private java.util.Date getDayOfMonth(java.util.Date instDate) {
    DateTimeZone zone = DateTimeZone.forID("Asia/Colombo");
    DateTime insDateE = new DateTime(new SimpleDateFormat("yyyy-MM-dd").format(instDate), zone);
    DateTime nowDate = insDateE.withDayOfMonth(25);
    return nowDate.toDate();
}

From source file:com.court.controller.MemberfxmlController.java

private java.util.Date[] setInstallmentDates(int insts, LoanPayment lpLast) {
    java.util.Date lstDate = lpLast != null ? lpLast.getInstallmentDate() : new java.util.Date();
    DateTimeZone zone = DateTimeZone.forID("Asia/Colombo");
    DateTime ld = new DateTime(new SimpleDateFormat("yyyy-MM-dd").format(lstDate), zone);
    java.util.Date furueDates[] = new java.util.Date[insts];
    for (int i = 0; i < insts; i++) {
        furueDates[i] = ld.plusMonths(i + 1).toDate();
    }/*from www .j  av  a2  s.  c  om*/
    return furueDates;
}

From source file:com.court.controller.MemberfxmlController.java

private java.util.Date[] setInstallmentDates2(int insts, java.util.Date lpLast) {
    java.util.Date lstDate = lpLast != null ? lpLast : new java.util.Date();
    DateTimeZone zone = DateTimeZone.forID("Asia/Colombo");
    DateTime ld = new DateTime(new SimpleDateFormat("yyyy-MM-dd").format(lstDate), zone);
    java.util.Date furueDates[] = new java.util.Date[insts];
    for (int i = 0; i < insts; i++) {
        furueDates[i] = ld.plusMonths(i + 1).toDate();
    }/*w w w  . jav a  2 s.  c o  m*/
    return furueDates;
}

From source file:com.court.handler.FxUtilsHandler.java

public static Predicate<MemberLoan> checkIfNotYetPaid(Function<MemberLoan, Date> check_date) {
    DateTimeZone zone = DateTimeZone.forID("Asia/Colombo");
    YearMonth ym_now = YearMonth.now(zone);

    return t -> {
        YearMonth ym_last = YearMonth.fromDateFields(new DateTime(check_date.apply(t), zone).toDate());
        //            if (t.getId() == 206) {
        //                YearMonth lastPaid = YearMonth.fromDateFields(new DateTime(check_date.apply(t), zone).toDate());
        //                System.out.println(ym_now.isAfter(lastPaid) || ym_now.isEqual(lastPaid));
        //                System.exit(0);
        //            }
        boolean flag = check_date.apply(t) != null
                ? (t.isContinuousPay() ? true : (ym_now.isAfter(ym_last) || ym_now.isEqual(ym_last)))
                : true;//from   w  w  w  . j av  a2s.c o  m
        // boolean flag = check_date.apply(t) != null ? (ym_now.isAfter(ym_last) || ym_now.isEqual(ym_last)) : true;
        return flag;
    };
}