Class: javajava::sql::Date

Inherits:
Object show all
Defined in:
lib/jactive_support/java_ext/sql_date/conversions.rb,
lib/jactive_support/java_ext/sql_date/localize.rb

Constant Summary collapse

DATE_FORMATS =
{
  :db           => "yyyy-MM-dd",
  :i18n         => lambda { |clazz, locale| clazz.i18n_formatter(locale: locale) },
  :number       => "yyyyMMdd",
  :full         => lambda { |clazz, locale| clazz.date_instance(:full, locale) },
  :long         => lambda { |clazz, locale| clazz.date_instance(:long, locale) },
  :medium       => lambda { |clazz, locale| clazz.date_instance(:medium, locale) },
  :short        => lambda { |clazz, locale| clazz.date_instance(:short, locale) },
  :default      => lambda { |clazz, locale| clazz.date_instance(:default, locale) },
  :rfc822       => "EEE, dd MMM yyyy HH:mm:ss Z",
  :httpdate     => lambda { |clazz, locale|
    fmt = clazz.pattern_formatter("EEE, dd MMM yyyy HH:mm:ss z", locale || 'EN')
    fmt.time_zone = 'GMT'.to_java_time_zone
    fmt
  }
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_formatter(locale) ⇒ Object



8
9
10
# File 'lib/jactive_support/java_ext/sql_date/localize.rb', line 8

def self.default_formatter(locale)
  date_instance(:default, locale)
end

.i18n_scopeObject



4
5
6
# File 'lib/jactive_support/java_ext/sql_date/localize.rb', line 4

def self.i18n_scope
  :sql_date
end

.parse(str, options = {}) ⇒ Object



12
13
14
15
# File 'lib/jactive_support/java_ext/sql_date/localize.rb', line 12

def self.parse(str, options = {})
  date = super
  self.new(date.time)
end

.parse_i18n(str, options = {}) ⇒ Object



17
18
19
20
# File 'lib/jactive_support/java_ext/sql_date/localize.rb', line 17

def self.parse_i18n(str, options = {})
  date = super
  self.new(date.time)
end

Instance Method Details

#acts_like_time?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/jactive_support/java_ext/sql_date/conversions.rb', line 25

def acts_like_time?
  false
end

#to_java_sqldateObject



21
22
23
# File 'lib/jactive_support/java_ext/sql_date/conversions.rb', line 21

def to_java_sqldate
  self
end