Created
September 15, 2012 20:09
-
-
Save migane/3729548 to your computer and use it in GitHub Desktop.
Date locale/us in jruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# jruby01.rb | |
require 'java' | |
java_import('java.util.Date') { |pkg, name| 'JDate' } | |
# To get the locales | |
java_import('java.util.Locale') { |pkg, name| 'JLocale'} | |
java_import('java.text.DateFormat') | |
# Get the date in local format | |
date = JDate.new | |
date_format = DateFormat.get_date_instance | |
date_locale = date_format .format date | |
puts date_locale | |
# Get the date in us format | |
date_format = DateFormat.get_date_instance(DateFormat::LONG, JLocale::US) | |
date_us = date_format .format date | |
puts date_us |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment