草庐IT

put_time

全部标签

java - 如何防止 Joda Time 在巴西 DST 过渡期间抛出异常

今天,我们的巴西用户正在为我们生成大量崩溃报告。我已经追踪到这段代码,它抛出了一个Joda异常:importorg.joda.time.DateTime;importorg.joda.time.DateTimeUtils;importorg.joda.time.DateTimeZone;importorg.joda.time.LocalTime;publicclassScratchSpace{publicstaticvoidmain(String[]args){//forceJodatoactlikeweareinSaoPaoloon2015-10-18DateTimeUtils.se

Java8 java.time : how to change the day of the week and the start time of the day?

假设我希望我的一周从星期二开始,这一天应该从早上5:30开始。这意味着,像这样的代码应该可以工作://LocalDateTimescreatedwiththe"standard"ISOtimeLocalDateTimetuesday_4_30=LocalDateTime.now().with(TemporalAdjusters.next(DayOfWeek.TUESDAY)).withHour(4).withMinute(30);LocalDateTimetuesday_6_30=tuesday_4_30.withHour(6).withMinute(30);LocalDateTime

java - 如何通过 time4j 将 24 小时制时间转换为 AM/PM 并将纳秒转换为秒?

我面临的问题是我需要将时间从24格式转换为AM/PM格式(反之亦然),通过time4j库删除冗余值,例如纳秒和秒。我正在使用time4j库,因为Java无法处理Windows时区,我必须通过time4j转换它们从24小时格式转换为AM/PM将取决于用户本地化。我想把它(本地化)作为一个论点来传递。本地化看起来像“en-US”字符串。例如:如果用户本地化为“en-US”,则将24小时格式转换为AM/PM。否则保持当前值。或者当我已经定义了用户的本地化时,以我需要的格式获取时间可能更好?任何想法如何做到这一点?请帮助)我必须花很多时间阅读time4jdoc但我的心被吹走了全面了解我正在做的

java - 为什么 setLastModified(time) 不适用于此文件?

为什么下面代码中的文件日期没有变?fLocal.location=C:\中的现有文件fLocal.date=以长整型设置的日期booleanx=newFile(fLocal.location).setLastModified(Long.parseLong(fLocal.date));System.out.println("Changed:"+x);System.out.println(newDate(newFile(fLocal.location).lastModified()));System.out.println(newDate(Long.parseLong(fLocal.dat

java - Logback MDC put() 可变对象

我正在使用Vaadin框架,它对拦截事件的支持很差,我无法知道session或UI何时被激活,所以我无法将它们的ID放入MDC。通常我会:publicvoidonSessionBegin(){MDC.put("session",VaadinSession.getCurrent().toString());//但是我没有这样的事件,所以我想://intheservletinitorwhereverMDC.put("session",newObject(){publicStringtoString(){VaadinSession.getCurrent().toString()};});//

java - 尝试使用 Spring-WS - "Connection timed out"访问 WS 服务器,但服务器在使用 SOAP UI 测试时响应

问题我正在接管JavaWeb服务客户端的开发工作,为了测试改进,我必须从远程Web服务服务器(嵌入在运行在tomcat实例中的ApacheAxis2中)请求一个方法。首先,我使用服务器提供的WSDL通过SOAPUI请求该方法。它工作正常。现在我尝试通过我的JavaWeb服务客户端请求该方法,但我无法连接到服务器,即使使用SOAPUI的测试证明一切正常。JavaWeb服务客户端依赖于Spring-WS。从客户端调用网络服务//SettingthekycScoreRequest...//TryingtoconnectandtogetthekycScoreResponseKycScoreRe

java.sql.Time 异常

有人遇到过这样的事情吗?切换到JAVA9后我遇到了这样的问题Causedby:java.lang.NoClassDefFoundError:java/sql/Timeatcom.google.gson.Gson.(Gson.java:240)atcom.google.gson.GsonBuilder.create(GsonBuilder.java:569)atnet.thucydides.core.reports.json.gson.GsonJSONConverter.(GsonJSONConverter.java:50)atnet.thucydides.core.reports.js

java - 如何在并发线程中操作 "ConcurrentModificationException"和 `values()` 时避免 HashMap `put()`?

代码:我有一个哈希表privateMapmap=newHashMap();一种方法通过调用put(K,V)将K-V对放入其中。另一种方法想要从它的值中提取一组随机元素:intsize=map.size();//size>0V[]value_array=map.values().toArray(newV[size]);Randomrand=newRandom();intstart=rand.nextInt(size);intend=rand.nextInt(size);//returnvalue_array[start..end-1]这两个方法在两个不同的并发线程中被调用。错误:我遇到了

java - 网络驱动程序异常 : unknown error: cannot determine loading status from timeout: Timed out receiving message from renderer: 60 using Selenium and Java

在我的Java项目中,我使用Selenium进行Web自动化。我正在使用chromedriverv2.20可执行文件。首先“ChromeDriverService”被初始化,用于创建ChromeDriver,如“newChromeDriver(service,capabilities);”。我还使用BrowserMobProxy来捕获所有Web请求。在我的测试中,我多次导航到某些URL,在每个导航驱动程序隐式等待几秒钟之后,然后轮询结果。但是在执行时它给了我超时异常。在我的研究中,我遇到了不适合我的解决方案:使用Thread.sleep而不是implicitlyWait替换新的Remo

java - 如何注释 JAXB 属性以使用 xsd :time rather than xsd:datetime?

我有一个这样的JAXB类:publicclassGame{privateDatestartTime;@XmlElementpublicDategetStartTime(){returnstartTime;}publicvoidsetStartTime(DatestartTime){this.startTime=startTime;}}这会生成.xsd,其中startTime的类型为xsd:datetime。我希望它是xsd:time。xsd:time映射到XmlGregorianCalendar,但反向映射映射到xsd:anySimpleType,这不是很有用。我尝试了@XmlElem