• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IllegalInstantException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.joda.time.IllegalInstantException的典型用法代码示例。如果您正苦于以下问题:Java IllegalInstantException类的具体用法?Java IllegalInstantException怎么用?Java IllegalInstantException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IllegalInstantException类属于org.joda.time包,在下文中一共展示了IllegalInstantException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getInterval

import org.joda.time.IllegalInstantException; //导入依赖的package包/类
/**
 * Put together the date given with the hours to create a POJO for the time interval in
 * which the dining hall is open.
 * Any time before 6:00am is assumed to be from the next day rather than the given date.
 * @param date Date string in yyyy-MM-dd format
 * @return Time interval in which meal is open represented as a Joda Interval
 */
public Interval getInterval(String date) {
    String openTime = date + " " + open;
    String closeTime = date + " " + close;
    // Avoid midnight hour confusion as API returns both 00:00 and 24:00
    // Switch it to more comprehensible 23:59 / 11:59PM
    if (close.equals("00:00:00") || close.equals("24:00:00")) {
        closeTime = date + " " + "23:59:59";
    }
    DateTime openInstant = DateTime.parse(openTime, DATEFORMAT);
    DateTime closeInstant;
    try {
        closeInstant = DateTime.parse(closeTime, DATEFORMAT);
    } catch (IllegalInstantException e) {
        closeTime = date + " " + "01:00:00";
        closeInstant = DateTime.parse(closeTime, DATEFORMAT);
    }

    // Close hours sometimes given in AM hours of next day
    // Cutoff for "early morning" hours was decided to be 6AM
    if (closeInstant.getHourOfDay() < 6) {
        closeInstant = closeInstant.plusDays(1);
    }

    return new Interval(openInstant, closeInstant);
}
 
开发者ID:pennlabs,项目名称:penn-mobile-android,代码行数:33,代码来源:VenueInterval.java


示例2: toJodaDateTime

import org.joda.time.IllegalInstantException; //导入依赖的package包/类
/**
 * Converts dateUnit to Joda-Time DateTime with a specific chronology.
 *
 * @param chronology Chronology to use
 * @return Populated DateTime object
 */
public DateTime toJodaDateTime( Chronology chronology )
{
    try
    {
        return new DateTime( year, month, day, hour, minute, second, millis, chronology.withZone( DateTimeZone.forTimeZone( timeZone ) ) );
    }
    catch ( IllegalInstantException ex )
    {
        LocalDateTime localDateTime = new LocalDateTime( year, month, day, hour, minute, second, millis,
            chronology.withZone( DateTimeZone.forTimeZone( timeZone ) ) );

        return localDateTime.toLocalDate().toDateTimeAtStartOfDay();
    }
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:21,代码来源:DateTimeUnit.java


示例3: localToUTC

import org.joda.time.IllegalInstantException; //导入依赖的package包/类
/**
 * @param localInstant  the instant from 1970-01-01T00:00:00 local time
 * @return the instant from 1970-01-01T00:00:00Z
 */
private long localToUTC(long localInstant) {
    DateTimeZone zone = getZone();
    int offset = zone.getOffsetFromLocal(localInstant);
    localInstant -= offset;
    if (offset != zone.getOffset(localInstant)) {
        throw new IllegalInstantException(localInstant, zone.getID());
    }
    return localInstant;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:14,代码来源:ZonedChronology.java


示例4: set

import org.joda.time.IllegalInstantException; //导入依赖的package包/类
public long set(long instant, int value) {
    long localInstant = iZone.convertUTCToLocal(instant);
    localInstant = iField.set(localInstant, value);
    long result = iZone.convertLocalToUTC(localInstant, false, instant);
    if (get(result) != value) {
        IllegalInstantException cause = new IllegalInstantException(localInstant,  iZone.getID());
        IllegalFieldValueException ex = new IllegalFieldValueException(iField.getType(), Integer.valueOf(value), cause.getMessage());
        ex.initCause(cause);
        throw ex;
    }
    return result;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:13,代码来源:ZonedChronology.java


示例5: updateEndTimeAsia

import org.joda.time.IllegalInstantException; //导入依赖的package包/类
public void updateEndTimeAsia(String time, int start_hour, int close_hour, int liquide_hour, int liquide_min)
{
    String date_delims = "[ ]+";
    String ddelims = "[-]"; 
    
    String[] date_tokens = time.split(date_delims); 
    String[] intdates = date_tokens[0].split(ddelims);     
  
    int signal_min = liquide_min;
    
    try
    {
        startTimeDT = new DateTime((new Integer(intdates[0])).intValue(), (new Integer(intdates[1])).intValue(), (new Integer(intdates[2])).intValue(),start_hour,signal_min);
    }
    catch(IllegalInstantException ie)
    {
        startTimeDT = new DateTime((new Integer(intdates[0])).intValue(), (new Integer(intdates[1])).intValue(), (new Integer(intdates[2])).intValue(),start_hour+1,signal_min);
    }

    endTimeDT = new DateTime((new Integer(intdates[0])).intValue(), (new Integer(intdates[1])).intValue(), (new Integer(intdates[2])).intValue(),close_hour,signal_min);
    liquidateTimeDT = new DateTime((new Integer(intdates[0])).intValue(), (new Integer(intdates[1])).intValue(), (new Integer(intdates[2])).intValue(), liquide_hour, liquide_min);
    
    if(liquide_hour > start_hour && liquidateTimeDT.dayOfWeek().getAsText().equals("Friday"))
    {liquidateTimeDT = liquidateTimeDT.plusDays(2);}
    
    //--- assume starting after 10am HST (16.00 EST or 4pm EST) produces new system setup for next day
    //System.out.println(cur_hour);
  
     if(close_hour < start_hour)
     {
         endTimeDT = endTimeDT.plusDays(1); 
         
         if(endTimeDT.dayOfWeek().getAsText().equals("Saturday"))
         {
             endTimeDT = endTimeDT.plusDays(2);
         }   
     }
     else if(endTimeDT.dayOfWeek().getAsText().equals("Friday"))
     {
         endTimeDT = endTimeDT.plusDays(2);
     }
     
     if(liquide_hour < start_hour)
     {liquidateTimeDT = liquidateTimeDT.plusDays(1);} 
     
     if(liquidateTimeDT.dayOfWeek().getAsText().equals("Saturday"))
     {liquidateTimeDT = liquidateTimeDT.plusDays(2);}
     
     //System.out.println("Updated start/close at " + startTimeDT + " " + endTimeDT + " " + liquidateTimeDT);
     
     
}
 
开发者ID:clisztian,项目名称:iMetrica,代码行数:53,代码来源:MDFAStrategyEvolution.java


示例6: computeMillis

import org.joda.time.IllegalInstantException; //导入依赖的package包/类
/**
 * Computes the parsed datetime by setting the saved fields.
 * This method is idempotent, but it is not thread-safe.
 *
 * @param resetFields false by default, but when true, unsaved field values are cleared
 * @param text optional text being parsed, to be included in any error message
 * @return milliseconds since 1970-01-01T00:00:00Z
 * @throws IllegalArgumentException if any field is out of range
 * @since 1.3
 */
public long computeMillis(boolean resetFields, String text) {
    SavedField[] savedFields = iSavedFields;
    int count = iSavedFieldsCount;
    if (iSavedFieldsShared) {
        iSavedFields = savedFields = (SavedField[])iSavedFields.clone();
        iSavedFieldsShared = false;
    }
    sort(savedFields, count);
    if (count > 0) {
        // alter base year for parsing if first field is month or day
        DurationField months = DurationFieldType.months().getField(iChrono);
        DurationField days = DurationFieldType.days().getField(iChrono);
        DurationField first = savedFields[0].iField.getDurationField();
        if (compareReverse(first, months) >= 0 && compareReverse(first, days) <= 0) {
            saveField(DateTimeFieldType.year(), iDefaultYear);
            return computeMillis(resetFields, text);
        }
    }

    long millis = iMillis;
    try {
        for (int i = 0; i < count; i++) {
            millis = savedFields[i].set(millis, resetFields);
        }
        if (resetFields) {
            for (int i = 0; i < count; i++) {
                millis = savedFields[i].set(millis, i == (count - 1));
            }
        }
    } catch (IllegalFieldValueException e) {
        if (text != null) {
            e.prependMessage("Cannot parse \"" + text + '"');
        }
        throw e;
    }
    
    if (iOffset != null) {
        millis -= iOffset;
    } else if (iZone != null) {
        int offset = iZone.getOffsetFromLocal(millis);
        millis -= offset;
        if (offset != iZone.getOffset(millis)) {
            String message = "Illegal instant due to time zone offset transition (" + iZone + ')';
            if (text != null) {
                message = "Cannot parse \"" + text + "\": " + message;
            }
            throw new IllegalInstantException(message);
        }
    }
    
    return millis;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:63,代码来源:DateTimeParserBucket.java



注:本文中的org.joda.time.IllegalInstantException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SinkTaskContext类代码示例发布时间:2022-05-22
下一篇:
Java ILogger类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap