だから私は後ろのアイテム"properties{"CreationDate"]
をJoda-Timeに変換するスクリプトを作ろうとしています。しかし、私はエラーが発生し続けます。
Creationdateは、2014年2月25日10:20の日付の私のプログラムのプロパティフィールドです。でもジョバタイムに欲しいです。このように:2014 M2 25、水10:20:09 GMT + 02:00
日付が作成日より遅れているため、日付を入力するスクリプトを作成できません。そして、その背後にはたくさんの日付があります。
「creationdate」の後ろに多くの異なる日付があるため、コードで日付を使用できません
require 'date'
items = $current_selected_items
items.each do |email|
properties = email.getProperties
date_time = properties["CreationDate"]
date_time.strftime("%m/%d/%Y %H:%M:%S")
date_time.strftime("%Y M%m %d, %a %H:%M:%S %Z")
end
エラー:
NoMethodError: undefined method `strftime' for "2/25/2014 10:20":String
Did you mean? strip
block in (root) at <script>:6
<main> at <script>:3
Script failed due to an error:
org.jruby.embed.EvalFailedException: (NoMethodError) undefined method `strftime' for "2/25/2014 10:20":String
Did you mean? strip
at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:131)
at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:90)
at org.jruby.embed.jsr223.JRubyEngine.eval(JRubyEngine.java:142)
at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.nuix.script.e.a(SourceFile:59)
at java.security.AccessController.doPrivileged(Native Method)
at com.nuix.script.e.a(SourceFile:56)
at com.sun.proxy.$Proxy46.eval(Unknown Source)
at com.nuix.script.j.a(SourceFile:53)
at com.nuix.investigator.script.m.e(SourceFile:326)
at com.nuix.investigator.script.m.c(SourceFile:277)
at com.nuix.investigator.script.m.doInBackground(SourceFile:180)
at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at javax.swing.SwingWorker.run(SwingWorker.java:334)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `strftime' for "2/25/2014 10:20":String
Did you mean? strip
at RUBY.block in (root)(<script>:6)
at RUBY.<main>(<script>:3)
strftimeを使用している変数は文字列です。つまり、strftimeを使用するには変数を変換する必要があります。
「date_time.strftime("%m/%d/%Y %H:%M:%S")
」で使用しているものと同様の正しい形式を渡すstrptimeを使用できます。次のコマンドを試してください。
require 'date'
string = DateTime.strptime(properties['CreationDate'], '%d/%M/%Y %H:%M')
puts string.strftime("%Y M%m %d, %a %H:%M:%S %Z")
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加