I have an Oracle database which contains a field W_PLANNED_DATE: 19/03/2013 10:55:00 (Date) In Java I put this value into a variable: Date dteBeginOrWaitingItem = orWaitinglist.getWPlannedDate(); value: 2013-03-19 Now, what happend to my time? I need this to fill the schedulecomponent of primefaces. How can i get a full date and time value eventResourceAvailPerDay.addEvent(new DefaultSche
我有一个Oracle数据库,其中包含一个字段W_PLANNED_DATE: 19/03/2013 10:55:00 (Date) 在Java中,我把这个值放入一个变量中: Date dteBeginOrWaitingItem = orWaitinglist.getWPlannedDate(); value: 2013-03-19 现在,我的时代到底发生了什么? 我需要这个来填充primefaces的schedulecomponent。 我如何获得完整的日期和时间值 eventResourceAvailPerDay.addEvent(new DefaultScheduleEvent(reason, dteBeginOrWaitingI
I'm trying to parse a date from a String and get the long value. The long value will be later sent to an SQL query. here's my code: String dayDate = "28-02-2013"; SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); Date day = new Date(); try { day = sdf.parse(dayDate); } catch (ParseException pe) { pe.printStackTrace(); } System.out.println("day : "+day.toSt
我试图从一个字符串解析日期并获得长期价值。 稍后的值将被发送到SQL查询。 这是我的代码: String dayDate = "28-02-2013"; SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); Date day = new Date(); try { day = sdf.parse(dayDate); } catch (ParseException pe) { pe.printStackTrace(); } System.out.println("day : "+day.toString()+ " long : " + day.getTime()); 它给出了以下输
Possible Duplicate: Calculating difference in dates in Java How do you subtract Dates in Java? I am parsing two dates from a string that look like: Oct 15, 2012 1:07:13 PM Oct 23, 2012 03:43:34 PM What I need to do is find the difference between these two dates, ex: Oct 23, 2012 03:43:34 PM - Oct 15, 2012 1:07:13 PM = 8 days 2 hours 36 minutes 21 seconds ^ This is what I need to get w
可能重复: 计算Java中的日期差异 你如何减去Java中的日期? 我从一个字符串解析两个日期,如下所示: Oct 15, 2012 1:07:13 PM Oct 23, 2012 03:43:34 PM 我需要做的是找到这两个日期之间的差异,例如: Oct 23, 2012 03:43:34 PM - Oct 15, 2012 1:07:13 PM = 8天2小时36分21秒 ^这是我所需要的两个日期/时间 我相信我需要解析格式并将其转换为另一种格式,然后减去两者之间的差异,并进行数学计算以获得日期/小
I have the below code: DateFormat df = new SimpleDateFormat("M/d/yy h:mm a z"); df.setLenient(false); System.out.println(df.parse("6/29/2012 5:15 PM IST")); Assuming I now set my PC's timezone to Pacific Time (UTC-7 for PDT), this prints Fri Jun 29 08:15:00 PDT 2012 Isn't PDT 12.5 hours behind IST (Indian Standard Time)? This problem does not occur for any other timezone - I tried
我有以下代码: DateFormat df = new SimpleDateFormat("M/d/yy h:mm a z"); df.setLenient(false); System.out.println(df.parse("6/29/2012 5:15 PM IST")); 假设我现在将我的PC的时区设置为太平洋时间(UTC-7 for PDT),打印出来 星期五6月29日08:15:00 PDT 2012 印度标准时间(印度标准时间)之后12.5小时是不是PDT? 这个问题不会发生在任何其他时区 - 我在日期字符串中尝试了UTC,PKT,MMT等而不是IST。 Java中有
I want to calculate the time difference between two dates (in the format "yyyyMMddHHmmss"). The basic idea is to first convert the string date into milliseconds and then get the time difference. Calendar c1 = Calendar.getInstance(); c1.setTime(new SimpleDateFormat("yyyyMMddHHmmss").parse("20110327032913")); System.out.println(c1.getTimeInMillis()); Calendar c2 = Calendar.getInstance()
我想计算两个日期之间的时间差(格式为“yyyyMMddHHmmss”)。 基本思想是首先将字符串日期转换为毫秒,然后获取时间差。 Calendar c1 = Calendar.getInstance(); c1.setTime(new SimpleDateFormat("yyyyMMddHHmmss").parse("20110327032913")); System.out.println(c1.getTimeInMillis()); Calendar c2 = Calendar.getInstance(); c2.setTime(new SimpleDateFormat("yyyyMMddHHmmss").parse("20110327025913")); System.out
To make a JDBC query I need to pass date to it. The date is kept in Date field type of PostgreSql database, which represents specific day without any time. As I need only date, I decided to use specific object which represent only date without time, which is LocalDate from Joda-Time package. I thought it is important because if I used DateTime object, it would carry redundant time data as wel
为了创建JDBC查询,我需要将日期传递给它。 日期保存在PostgreSql数据库的Date字段类型中,该Date字段类型表示没有任何时间的特定日期。 由于我只需要日期,因此我决定使用仅表示没有时间的日期的特定对象,即Joda-Time包中的LocalDate 。 我认为这很重要,因为如果我使用DateTime对象,它会携带冗余的时间数据,并且在时钟倒退一个小时时可能导致夏令时结束时出现错误(尽管情况是前所未有的罕见,但不是不可能)。 但是
Is there a Java equivalent of DateTime.MinValue and DateTime.Today in the Java Date class? Or a way of achieving something similar? I've realised how spoilt you are with the .NET datetime class, I also need the equivalent of AddDays(), AddMonths(). The de-facto Java datetime API is joda-time. With it, you can get the current date/time by just constructing new DateTime() . Similarly,
Java Date类中有DateTime.MinValue和DateTime.Today的Java等价物吗? 或者实现类似的方式? 我已经意识到如何使用.NET datetime类,我也需要相当于AddDays(),AddMonths()。 事实上的Java日期时间API是joda时间。 有了它,只需构建new DateTime()即可获取当前的日期/时间。 同样,如果没有它,您可以使用Calendar.getInstance()或new Date()来获取当前日期/时间。 MinValue可以是Calendar.getInstance(0) / new D
I'm trying to parse a string to a date field in an android application but I can't seem to get it correct. Here is the string I'm trying to convert to a date "03/26/2012 11:49:00 AM". The function I'm using is: private Date ConvertToDate(String dateString){ SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa"); Date convertedDate = new D
我试图解析一个字符串到android应用程序中的日期字段,但我似乎无法得到它正确的。 这是我试图转换为日期“03/26/2012 11:49:00 AM”的字符串。 我使用的功能是: private Date ConvertToDate(String dateString){ SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa"); Date convertedDate = new Date(); try { convertedDate = dateFormat.parse(dateString); } catch (Par
Continuing from Stack Overflow question Java program to get the current date without timestamp: What is the most efficient way to get a Date object without the time? Is there any other way than these two? // Method 1 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date dateWithoutTime = sdf.parse(sdf.format(new Date())); // Method 2 Calendar cal = Calendar.getInstance(); cal.set(C
继续从堆栈溢出问题Java程序获取当前日期没有时间戳: 在没有时间的情况下获取Date对象的最有效方法是什么? 除了这两个之外还有别的方法吗? // Method 1 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date dateWithoutTime = sdf.parse(sdf.format(new Date())); // Method 2 Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.S
I am relatively new to Java, and often find that I need to sort a Map<Key, Value> on the values. Since the values are not unique, I find myself converting the keySet into an array , and sorting that array through array sort with a custom comparator that sorts on the value associated with the key. Is there an easier way? 这是一个通用友好的版本: public class MapUtil { public static
我对Java比较陌生,经常发现我需要对值进行Map<Key, Value>排序。 由于这些值不是唯一的,所以我发现自己将keySet转换为一个array ,并通过数组排序并使用自定义比较器 对数组进行排序 ,该比较器对与键关联的值进行排序。 有更容易的方法吗? 这是一个通用友好的版本: public class MapUtil { public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map