1

i am developing a Google-Calendar alike using Zk-Calendar i have a question about java.text.SimpleDateFormat here is some code

1). how to get the day and month in first letter uppercase is this possible?

here is the code i'm using so far.

private final SimpleDateFormat dformat = new SimpleDateFormat("EEEE dd-MMMMM-yyyy HH:mm:ss a");
private void printDateTester() 
{
    final Locale VENEZUELA_LOCALE = new Locale("es","VE");
    Locale locale = Locale.getDefault();
    System.out.println(locale.getDisplayCountry()+" "+locale.getCountry());//prints United States US
    System.out.println(VENEZUELA_LOCALE.getDisplayCountry()+" "+VENEZUELA_LOCALE.getCountry());//prints Venezuela VE
    final Calendar TODAY_US  = Calendar.getInstance(locale);
    final Calendar TODAY_VEN = Calendar.getInstance(VENEZUELA_LOCALE);
    System.out.println(dformat.format(TODAY_US.getTime())); //prints sábado 10-agosto-2013 11:07:55 AM  
    System.out.println(dformat.format(TODAY_VEN.getTime()));//prints sábado 10-agosto-2013 11:07:55 AM    
}  

it prints something like sabado 10-agosto-2013 09:42:24 AM in english something like saturday 10-august-2013 but i would like something like Saturday 10-August-2013 09:42:24 AM is this possible?

any ideas thanks a lot.

UPDATE

i have create 2 SimpleDateFormats 1 using Locale.US and 2 other using either Venezuela Locale and Spain Locale the US version prints in Uppercase but both Venezuela and Spain locales prints in lowercase but i need show the data in Spanish why is this??

final Locale VENEZUELA_LOCALE = new Locale("es","VE");
Locale locale = Locale.getDefault();        
final SimpleDateFormat dformatI  = new SimpleDateFormat("EEEE dd-MMMMM-yyyy HH:mm:ss a",VENEZUELA_LOCALE);        
final SimpleDateFormat dformatII = new SimpleDateFormat("EEEE dd-MMMMM-yyyy HH:mm:ss a",Locale.US);        

Locale: Venezuela VE
print: domingo 11-agosto-2013 09:24:25 AM
Locale: United States US
print: Sunday 11-August-2013 09:24:25 AM
chiperortiz
  • 4,751
  • 9
  • 45
  • 79

1 Answers1

1

Have you tried setting Locale in DateTime format object:

    private final SimpleDateFormat dformat = new SimpleDateFormat("EEEE dd-MMMMM-yyyy HH:mm:ss a",Locale.US);

Not all languages are following US standard (Capitalized day and month names). Therefore what output value java DateTimeFormat is giving was expected.

You could find this interesting discussion in the following questions

How to control the capitalization of month and day names returned by DateFormat?

Community
  • 1
  • 1
Shamim Ahmmed
  • 8,265
  • 6
  • 25
  • 36
  • hello Shamim i have create 2 SimpleDateFormats one using Locale.US and other using Venezuela,Spain locales the US locale prints in Uppercase exactly as i want to but both Venezuela and Spain prints in lowercase with is this? i need print it in spanish.... – chiperortiz Aug 11 '13 at 13:56
  • i think so... thanks a lot... there is nothing i could do.. hehe. – chiperortiz Aug 11 '13 at 15:14