Sha256: fddea5ac9b4315f59dc6da8b83c0654ce4109af6a4ec978e1f14a2ba30605075

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

require 'jactive_support/java_ext/date/calculations'
require 'jactive_support/java_ext/date/conversions'

class java::util::Date
  include JactiveSupport::JavaExtensions::Date::Calculations
  include JactiveSupport::JavaExtensions::Date::Conversions

  FULL_STYLE = java::text::DateFormat::FULL
  LONG_STYLE = java::text::DateFormat::LONG
  MEDIUM_STYLE = java::text::DateFormat::MEDIUM
  SHORT_STYLE = java::text::DateFormat::SHORT
  DEFAULT_STYLE = java::text::DateFormat::DEFAULT
  
  STYLE = {
    :full => FULL_STYLE,
    :long => LONG_STYLE,
    :medium => MEDIUM_STYLE,
    :short => SHORT_STYLE,
    :default => DEFAULT_STYLE
  }
  
  def acts_like_time?
    true
  end
  
  def self.date_time_instance(date_style=:default, time_style=:default, locale=nil)
    java::text::DateFormat.getDateTimeInstance(STYLE[date_style], STYLE[time_style], locale.to_locale)
  end

  def self.time_instance(time_style=:default, locale=nil)
    java::text::DateFormat.getTimeInstance(STYLE[time_style], locale.to_locale)
  end

  def self.date_instance(date_style=:default, locale=nil)
    java::text::DateFormat.getDateInstance(STYLE[date_style], locale.to_locale)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
jactive_support-2.1.2 lib/jactive_support/java_ext/date.rb
jactive_support-2.1.1 lib/jactive_support/java_ext/date.rb
jactive_support-2.1.0 lib/jactive_support/java_ext/date.rb
jactive_support-2.0.0 lib/jactive_support/java_ext/date.rb
jactive_support-1.0.2 lib/jactive_support/java_ext/date.rb
jactive_support-1.0.1-universal-java-1.6 lib/jactive_support/java_ext/date.rb
jactive_support-1.0.0-universal-java-1.6 lib/jactive_support/java_ext/date.rb