我正在尝试使用12:00的小时初始化Joda-Time DateTime对象,这是我如何做到这一点:
public static final long MINUTE = 60 * 1000;
public static final long HOUR = 60 * MINUTE;
DateTime defaultDate = new DateTime(HOUR * 12);
System.out.print("the hour is: " + defaultDate.getHourOfDay()) // getting 14
Run Code Online (Sandbox Code Playgroud)
为什么我得到14而不是12?也许妈妈没教我怎么读时钟吧?!
如何使用Joda-Time datetime 解析日期字符串,该日期时间使用正确的时区和夏令时?
作为scala中的示例,我尝试解析字符串"2014-04-07 01:00:00.000"(没有时区信息).这个日期来自MySQL,应该在tz Europe/Berlin +01:00.我喜欢的是根据2014-04-07 00:00:00 + 01:00的joda约会时间,这是欧洲/柏林目前没有在DST(GMT +1)的时区.
val fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS").withZone(DateTimeZone.forID("Europe/Berlin"))
val dt = fmt.parseDateTime("2014-04-07 01:00:00.000")
Run Code Online (Sandbox Code Playgroud)
不幸的是,Joda-Time将日期解析为2014-04-07T01:00:00.000 + 02:00,这是当前错误的偏移(02:00而不是01:00)
任何想法如何让Joda-Time用正确的DST偏移解析日期?
我希望每次构建时,Xcode 5中的版本号(CFBundleVersion和CFBundleShortVersionString)都会自动设置为UTC时区的当前日期时间.
例如,201405041942手段May 4, 2014 at 7:42 PM UTC.
我之前从未使用过Joda-Time,但我有ArrayList,其中包含具有LocalDate和count的对象.所以我在ArrayList中计算每一天,每天只在ArrayList中使用一次.我需要计算一年中每个月的计数,这在列表中.
我的数据:例如:
dd.MM.yyyy
17.01.1996 (count 2)
18.01.1996 (count 3)
19.02.1996 (count 4)
19.03.1996 (count 1)
18.05.1997 (count 3)
Run Code Online (Sandbox Code Playgroud)
现在我想要outpur像这样:
MM.yyyy
01.1996 -> 2 (17.1.1996) + 3 (18.1.1996) = 5
02.1996 -> 4 (19.2.1996) = 4
03.1996 -> 1 (19.3.1996) = 1
05.1997 -> 3 (18.5.1997) = 3
Run Code Online (Sandbox Code Playgroud)
我只需要每个月计算,但我不知道最好的方法是什么.
数据类:
private class Info{
int count;
LocalDate day;
}
Run Code Online (Sandbox Code Playgroud)
结果我会在一些包含月份和年份日期+计数的类中输入.
在Vaadin Charts 2(刚刚发布的2014-12)中,我如何设置图表的标题和副标题?
默认字体大小很大.我在每个布局中显示多个图表,因此我无法承受如此多的空间浪费在标题上.
是否有一些命令或一些CSS钩子来控制标题的字体大小和边距/填充?
以下代码在印度返回"1970-01-01"为0L,在加拿大它返回"1969-12-31".我不知道这里出了什么问题,谁能告诉我这里有什么问题.我怀疑这是因为时区问题,但需要更多信息.
public static RestEDate convertLongDateToStringDate(long lDate) {
String returnDate = "";
if (lDate >= 0) {
returnDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date(lDate));
}
return new RestEDate(returnDate);
}
Run Code Online (Sandbox Code Playgroud) 在Android中,我用来java.util.Calendar获取格式为昨天的日期yyyy-MM-dd'T'hh:mm:ss'Z'。例如,如果今天是31 May 2017,我想将昨天的日期设为2017-05-30T00:00:00Z。
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// Date End = yesterday
calendar.add(Calendar.DATE, -1);
Date dateEnd = calendar.getTime();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
this.dateEndStr = formatter.format(dateEnd);
Run Code Online (Sandbox Code Playgroud)
我期望输出为2017-05-30T00:00:00Z. 但它给了我2017-05-30T12:00:00Z。
这里有什么问题吗?与时区有关吗?我的时区是GMT/UTC + 08:00 hour.
有什么方法可以确定两个BigDecimal对象中的哪一个是比(if或三元运算符)调用更简单的数字(更小)BigDecimal::compareTo?
鉴于:
BigDecimal x = … ;
BigDecimal y = … ;
Run Code Online (Sandbox Code Playgroud)
要么:
if( x.compareTo( y ) < 0 ) {
return x ;
} else {
return y ;
}
Run Code Online (Sandbox Code Playgroud)
要么:
BigDecimal lower = ( x.compareTo( y ) < 0 ) ? x : y ; // If x is smaller than y, use x. If x is greater than or equal to y, use y.
Run Code Online (Sandbox Code Playgroud) 我正在尝试了解Hazelcast库。在线研究表明它是一个内存数据网格并且适用于分布式网络。除此之外,我对理解这一点感到非常困惑。
如果错了请纠正我(我的理解)。这里在分布式网络上工作意味着一些数据存储在 Hazelcast 的内存数据网格中,集群中的所有节点都可以访问它?这是正确的吗 ?集群中的任何节点都可以对内存中的数据网格执行(插入、删除或更新),并且所有节点都可以使用该网格。
谁能帮我用任何例子简单地解释 Hazelcast 的主要目的是什么?
我从日期生成数字,我使用的是Integer.parseInt(myDateNumberString).
我的问题是,如果数字太大,它会给我一个错误.
public Integer currentDate(){
String current_date = new SimpleDateFormat("yyyyMMddHHmm").format(Calendar.getInstance().getTime());
//int _current_date = Integer.parseInt(current_date); // Error, too big number
int _current_date = new BigInteger(current_date).intValue();
return _current_date; // Error, output: -51212897
}
Run Code Online (Sandbox Code Playgroud)
我希望获得价值,201812250203
如果我的日期格式没有mm它是好的,但我需要声明它.