Advertisement
iGrind

Untitled

Dec 4th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.12 KB | None | 0 0
  1.  
  2.  
  3. val df = lg match{
  4.         case "ru" => {
  5.           new RussianDateFormatter()
  6.  
  7.         }
  8.         case "ms" => {
  9.           val locale = new Locale.Builder().setLanguage("en").build()
  10.           System.out.println(locale)
  11.          // df = new SimpleDateFormat("MMM. d, yyyy, h:mm a",locale )
  12.            DateTimeFormat.forPattern("d MMMM").withLocale(Locale.ENGLISH)
  13.  
  14.         }
  15.         case "ar" =>{
  16.           var locale = new Locale.Builder().setLanguage(lg).setScript("Arab").build()
  17.           DateTimeFormat.forPattern("MMMM d, yyyy, h:mm a").withLocale(locale)
  18.         }
  19.         case "zh" =>{
  20.           var locale = new Locale.Builder().setLanguage(lg).build()
  21.           DateTimeFormat.forPattern("MM d, yyyy, h:mm a").withLocale(locale)
  22.         }
  23.       }
  24.  
  25. // где RussianDateFormatter - class RussianDateFormatter extends DateTimeFormatter {
  26. // ... конструктор в котором только супер вызываешь
  27. // @Override
  28. // def parseDateTime(text: String) = super.parseDateTime(formatRussianString(text)) , где formatRussianString - твое форматирование строки
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement