jodatime

convert epoch to datetime in Scala / Spark

送分小仙女□ 提交于 2020-01-13 14:45:21
问题 I'm converting String representing a DateTime to unix_time (epoch) using : def strToTime(x: String):Long = { DateTimeFormat. forPattern("YYYY-MM-dd HH:mm:ss").parseDateTime(x).getMillis()/1000 } to get a list of Long like this : .map( p=> List( strToTime(p(0) ) ) ) my question is - what is the easiest way to turn in backwards? something like: def timeToStr(x: Long):String = { x*1000L.toDateTime} that I could use on the above List(Long) I have read Convert seconds since epoch to joda DateTime

convert epoch to datetime in Scala / Spark

China☆狼群 提交于 2020-01-13 14:44:50
问题 I'm converting String representing a DateTime to unix_time (epoch) using : def strToTime(x: String):Long = { DateTimeFormat. forPattern("YYYY-MM-dd HH:mm:ss").parseDateTime(x).getMillis()/1000 } to get a list of Long like this : .map( p=> List( strToTime(p(0) ) ) ) my question is - what is the easiest way to turn in backwards? something like: def timeToStr(x: Long):String = { x*1000L.toDateTime} that I could use on the above List(Long) I have read Convert seconds since epoch to joda DateTime

convert epoch to datetime in Scala / Spark

隐身守侯 提交于 2020-01-13 14:44:47
问题 I'm converting String representing a DateTime to unix_time (epoch) using : def strToTime(x: String):Long = { DateTimeFormat. forPattern("YYYY-MM-dd HH:mm:ss").parseDateTime(x).getMillis()/1000 } to get a list of Long like this : .map( p=> List( strToTime(p(0) ) ) ) my question is - what is the easiest way to turn in backwards? something like: def timeToStr(x: Long):String = { x*1000L.toDateTime} that I could use on the above List(Long) I have read Convert seconds since epoch to joda DateTime

convert epoch to datetime in Scala / Spark

帅比萌擦擦* 提交于 2020-01-13 14:44:33
问题 I'm converting String representing a DateTime to unix_time (epoch) using : def strToTime(x: String):Long = { DateTimeFormat. forPattern("YYYY-MM-dd HH:mm:ss").parseDateTime(x).getMillis()/1000 } to get a list of Long like this : .map( p=> List( strToTime(p(0) ) ) ) my question is - what is the easiest way to turn in backwards? something like: def timeToStr(x: Long):String = { x*1000L.toDateTime} that I could use on the above List(Long) I have read Convert seconds since epoch to joda DateTime

Joda DateTimeFormat with proper number suffix

情到浓时终转凉″ 提交于 2020-01-13 13:52:42
问题 I need to print a DateTime in the form of, for example, Wednesday, January 9th , where the day of month automatically gets the proper suffix, e.g. January 2 would be January 2nd . How can I get a DateTimeFormatter that does this? 回答1: There is no support for this in Joda, but with some limitations, you can use the ICU library, since it includes localized rules for formatting ordinal numbers: import com.ibm.icu.text.RuleBasedNumberFormat; import com.ibm.icu.text.SimpleDateFormat; ...

Migrating To Hibernate 5 from 3

南楼画角 提交于 2020-01-13 10:33:28
问题 I am migrating to Hibernate 5.0.3.Final from 3. In 3.x I am using joda-time to persist LocalDateTime in oracle DB. Now I am seeing that hibernate 5 doesn't have a support to joda-time. Please let me know what would be the best alternative for it? Here is code sample. import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.LocalDateTime; public class ComponentHistory { @Column(name = EntityConstants.CREATED_BY_COLUMN_NAME) private String createdBy; @Column(name =

Migrating To Hibernate 5 from 3

混江龙づ霸主 提交于 2020-01-13 10:33:16
问题 I am migrating to Hibernate 5.0.3.Final from 3. In 3.x I am using joda-time to persist LocalDateTime in oracle DB. Now I am seeing that hibernate 5 doesn't have a support to joda-time. Please let me know what would be the best alternative for it? Here is code sample. import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.LocalDateTime; public class ComponentHistory { @Column(name = EntityConstants.CREATED_BY_COLUMN_NAME) private String createdBy; @Column(name =

JodaTime with JPA, PostgreSQL and NULL values

一个人想着一个人 提交于 2020-01-13 08:29:24
问题 I'm trying to persists JodaTime DateTime fields with JPA to PostgreSQL but run into troubles with null pointers to database NULL values. I'm working with the NetBeans 7 beta 2 IDE. The persistence implementation is EclipseLink 2.2.0 and I'm using an EclipseLink Converter to get the mapping to work. Here is the declaration of my field: @Converter( name="dateTimeConverter", converterClass=ejb.util.DateTimeConverter.class ) @Column(columnDefinition="TIMESTAMP WITH TIME ZONE") @Convert(

Joda Time and hibernate 4

早过忘川 提交于 2020-01-12 07:54:10
问题 I am using hibernate 4 with joda time and spring data jpa. Spring data provides annotations @CreadedOn @LastModifiedOn i am trying to use these two annotations.Below is a snapshot of my pojo @Entity @Table(name="restaurant") @Audited public class Restaurant { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String restaurantName; @CreatedDate @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime") // @Type(type = "org.jadira.usertype.dateandtime

Joda Time and hibernate 4

空扰寡人 提交于 2020-01-12 07:54:05
问题 I am using hibernate 4 with joda time and spring data jpa. Spring data provides annotations @CreadedOn @LastModifiedOn i am trying to use these two annotations.Below is a snapshot of my pojo @Entity @Table(name="restaurant") @Audited public class Restaurant { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String restaurantName; @CreatedDate @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime") // @Type(type = "org.jadira.usertype.dateandtime