Formatting a date like: Friday 24th January

Formatting a date like: Friday 24th January
Is there any way using the Java API to get the 'th' or 'st' bits on the numbers.
I can't see it in java.text.SimpleDateFormat
Thanks.

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class DateFormatter {
     public static void main(String[] args) {
          Calendar calendar = new GregorianCalendar();
          double[] limits = {1, 2, 3, 4, 21, 22, 23, 24};
          String[] dateFormats = {"st", "nd", "rd", "th", "st", "nd", "rd", "th"};
          ChoiceFormat choiceFormat = new ChoiceFormat(limits, dateFormats);
          String dateFormat = "EEEEE dd''{0}'' MMMMM";
          MessageFormat messageFormat = new MessageFormat(dateFormat);
          messageFormat.setFormat(0, choiceFormat);
          Object[] msgArgs = {
               new Integer(calendar.get(Calendar.DATE))
          String message = messageFormat.format(msgArgs);
          System.out.println(message);
          SimpleDateFormat date = new SimpleDateFormat(message);
          System.out.println(date.format(calendar.getTime()));
}

Similar Messages

  • Formscentral - how do I change required date format to long date (e.g. January 2, 2014) in a form field?

    Formscentral - how do I change required date format to long date (e.g. January 2, 2014) in a form field?  I can't seem to change it from the short date format.

    Hi,
    I would suggest you to change the form language to English (UK), Here are the steps:-
    1. Open your form in FormsCentral
    2. Clik on Options tab
    3. Click on Language and Formatting and check out the selection for Form Language and make sure English (U.K.) is selected and the default date format should be day/month/year.
    Regards,
    Nakul

  • HOW TO GENARATE DATE LIKE 12 DEC 2007 USING xp20:format-dateTime(dateTime a

    HOW TO GENARATE DATE LIKE 12 DEC 2007 USING xp20:format-dateTime(dateTime as string, format as string). PLEASE HELP.

    If i look at the w3 org i would say :
    xp20:format-dateTime('yourfield','[D]-[[MN,*-3]-[Y]')
    or just MN will do too.

  • Changing date format to look like dd-mm-yyyy

    I want to use the date format as 25-12-2010 (day-month-year). I could not find how. Is there a place to change that? Can I make custom formats for dates?
    Hursat

    Hursat,
    I must admit, I just noticed that you are using Numbers 08. Perhaps there is something different in Numbers 09. If so, I apologize. I don't presently have access to Numbers 08 to check.
    Numbers 08 Help says:
    . To add and format the date and/or time, place the insertion point where you want the value to appear, and then choose Insert > Date & Time.
    . To change the date and time format, Control-click the date and time value, choose Edit Date & Time, and then choose a date and time format from the pop-up menu. If you want the spreadsheet to always show the current date and time, select “Automatically update on open.”
    Based on this help, there's not much difference. Try a text box and see if you can insert date and time there.
    Jerry

  • Format of Date field is loading wrongly in the Infocube 0pp_c01.

    Hi,
    Format of Date field is loading wrongly in the Infocube 0pp_c01. But it is loading properly into PSA.
    I am loading data into PP infocubes from the following DataSources.(they all are 3.x datasources)
    1. 2LIS_04_P_MATNR
    2. 2LIS_04_P_ARBPL
    3. 2LIS_04_P_COMP
    The data is coming properly upto PSA.  For example Actual Start date is loaded in cube like 733.884.
    And, it is the same issue with all the cubes. So I checked the update rules. But, in it the mapping is done properly.
    Thanks $ Regards
    Shyne Sasimohanan
    +91-9632674245

    Hi,
    HEre also value is loaded correctly. The reason u are seeing it in this format is because it is mapped into a key figure in the info cube.
    It will store the value as number of days from a standard date like 1/1/1000 or 1/1/1900 - not sure which one of these, u should be able to search and find the correct date in the forums..but this is the logic behind it
    Hope it helps.
    Regards,
    Rathy

  • Convert String to Date and Format the Date Expression in SSRS

    Hi,
    I have a parameter used to select a month and year  string that looks like:    jun-2013
    I can convert it to a date, but what I want to do is,  when a user selects a particular month-year  (let's say "jun-2013")
    I  populate one text box with the date the user selected , and (the challenge Im having is)  I want to populate a text box next to the first text box with the month-year  2 months ahead.    So if the user selects 
    jun-2013   textbox A will show  jun-2013 
    and textbox B will show  aug-2013..
    I have tried:
    =Format(Format(CDate(Parameters!month.Value  ),  
    "MM-YYYY"  )+ 2  )   -- But this gives an error
    This returns the month in number format   like "8"    for august...
    =Format(Format(CDate(Parameters!month.Value  ), 
    "MM"  )+ 2  )
    What is the proper syntax to give me the result    in this format =  "aug-2013"  ???
    Thanks in advance.
    MC
    M Collier

    You can convert a string that represents a date to a date object using the util.scand JavaScript method, and then format a date object to a string representation using the util.printd method. For more information, see:
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1254.html
    http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.1251.html
    In your case, the code would be something like:
    var sDate = "2013-01-10";
    // Convert string to date
    var oDate = util.scand("yyyy-mm-dd", sDate);
    // Convert date to new string
    var sDate2 = util.printd("mm/dd/yyyy", oDate);
    // Set a field value
    getField("date2").value = sDate2;
    The exact code you'd use depends on where you place the script and where you're getting the original date string, but this should get you started.

  • Mail.app/ToDo: How to change Input format of Date Due?

    Hello,
    I am using english version of Leopard 10.5.7 with international/Formats region setting set to german. In applications it usually results in dates like 23.12.2008 (dd.mm.yyyy).
    However, Mail.app's ToDo still requires me to enter mm/dd/yyyy dates ("month-first").
    How do I change it, so Mail.app also accepts european dd.mm.yyyy dates?
    Regards,
    t-80

    Hello,
    is there a chance to get a question answered?
    or shall one better contact apple support by phone?
    regards.

  • Formatting a date in XSLT

    I am working with an XSLT fragment in dreamweaver and all
    seems to be working fine except when it comes to the date field in
    the XML it is transforming. It looks like dreamweaver has no
    options in it for formatting a date. Looking on the web it appears
    that XSLT doesn't have a function for that except if you are
    running XSLT 2.0??
    my XML looks like
    <pubDate>Wed, 04 Apr 2007 04:00:00
    +0100</pubDate>
    Can anyone help me just show only this part, "Wed, 04 Apr
    2007"
    thanks
    chris

    >I am working with an XSLT fragment in dreamweaver and all
    seems to be
    >working
    > fine except when it comes to the date field in the XML
    it is transforming.
    > It
    > looks like dreamweaver has no options in it for
    formatting a date. Looking
    > on
    > the web it appears that XSLT doesn't have a function for
    that except if
    > you are
    > running XSLT 2.0??
    Correct.
    > my XML looks like
    > <pubDate>Wed, 04 Apr 2007 04:00:00
    +0100</pubDate>
    > Can anyone help me just show only this part, "Wed, 04
    Apr 2007"
    With XSLT, this should work:
    <xsl:value-of select="substring(pubDate,1,16)"
    order="descending" />
    The substring function variables are:
    substring(node, postition of start character in string, total
    number of
    characters to include)
    It's akin to a TRIM string statement in server-side
    programming languages.
    -Darrel

  • I don't want to allow a user to enter a date that is before January 2014

    I don't want to allow a user to enter a date that is before January 2014. I want to restrict users from entering a date that is or prior to December 31, 2013 in a date field. Is this possible?

    Seems like it is a little more complicated just to create a new Date() object in livecycle...
    the way I found to create a new Date() object is using the dateTimeEdit pattern to be 'date{EEEE, MMMM D, YYYY}'
    then u can create a new Date
    var date1 = new Date(DateTimeField1.editValue);
    date1.getTime();
    or
    you can also click the following link and download the pdf from the blog...
    Adobe LiveCycle Designer Cookbooks by BR001: Date handling in Livecycle Designer ES forms
    using XFADate object make it easy to manipulate dates with javascript
    The XFADate object created by BR001 is very good but to be able to see if a date is prior to another date you can just add this function in the object script..
    you can add that function at line 200...
    that.isPriorTo = function(date) {
         var toDate = newDate(date);
         if (isNaN(this) || isNaN(toDate)){
              return false;
         } else{
              var interval = this.getTime() - toDate.getTime();
              if (interval > 0){
                   return false;
              } else{
                   return true;
    To use that function above you can just use this code:
    if (XFADate.newDate(dateFrom).isPriorTo(DateTo)){
         //dateFrom is prior to dateTo
    hope this help

  • I need format for data in excel file load into info cube to planning area.

    Hi gurus,
    I need format for data in excel file load into info cube to planning area.
    can you send me what should i maintain header
    i have knowledge on like
    plant,location,customer,product,history qty,calander
    100,delhi,suresh,nokia,250,2011211
    if it is  right or wrong can u explain  and send me about excel file format.
    babu

    Hi Babu,
    The file format should be same as you want to upload. The sequence of File format should be same communication structure.
    Like,
    Initial columns with Characteristics (ex: plant,location,customer,product)
    date column (check for data format) (ex: calander)
    Last columsn with Key figures (history qty)
    Hope this helps.
    Regards,
    Nawanit

  • Formatting  a Date

    Hi, Can someone tell me how to simply format the date to this:
    MON DD, YYYY
    Thanks

    You can use the SimpleDateFormat like:
    java.text.DateFormat df = new java.text.SimpleDateFormat(format);where formar is a String like:
    format= "dd/MM/yyyy";for a date like "07/06/2003"
    You can use any format you want modifying the format using the following symbols:
    Symbol Meaning Presentation Example
    G era designator (Text) AD
    y year (Number) 1996
    M month in year (Text & Number) July & 07
    d day in month (Number) 10
    h hour in am/pm (1~12) (Number) 12
    H hour in day (0~23) (Number) 0
    m minute in hour (Number) 30
    s second in minute (Number) 55
    S millisecond (Number) 978
    E day in week (Text) Tuesday
    D day in year (Number) 189
    F day of week in month (Number) 2 (2nd Wed in July)
    w week in year (Number) 27
    W week in month (Number) 2
    a am/pm marker (Text) PM
    k hour in day (1~24) (Number) 24
    K hour in am/pm (0~11) (Number) 0
    z time zone (Text) Pacific Standard Time
    ' escape for text (Delimiter)
    '' single quote (Literal) '
    Juan Carlos

  • Formatting a date field auto populated with Javascript

    I have a date field, which I auto-populate to be the current days date with the following code:
    var date=new Date();
    var month=date.getMonth()+1;
    this.rawValue=month+"/"+date.getDate()+"/"+(date.getYear()-100);
    This works fine, but it comes out as 7/20/12 instead of 07/20/2012 like my pattern defines.
    Whether or not I write my code to be the correct format, I always get an "Invalid format" error. How can I fix this?

    The solutions is to format the date in YYYY-MM-DD when setting the raw value.
    var date=new Date();
    var month=date.getMonth()+1;
    var day=date.getDate();
    if(month<10){ month="0"+month; }
    if(day<10) {day="0"+day; }
    this.rawValue=date.getFullYear()+"-"+month+"-"+day;

  • Formatting a date according with user settings (user defaults)

    Hi All,
    I need to format a date I receive via JS in YYYYMMDD format according with user defaults <b>without</b> server side action (I know, this is not a good issue, but they want it).
    My solution is to write a JS function (there are a lot of it on WWW) which accepts two strings and formats the first according to the second, something like:
    userFormattedDate = formatDate('20060613','DD.MM.YYYY');
    paying attention to generate 'DD.MM.YYYY' string on server side, according to user settings.
    But if this isn't a weblog, where is the question? :-D
    The question is: is there a JS function (in DatePicker or dateNavigator BSP) provided by standard libraries which serves similar functionality?
    Does exist a JS public standard library?
    Thanks.
    Dany

    Hi Durairaj,
    Tags <% %> are for server side actions.
    The question is about obtaining the same effect, but client side.
    Thanks.
    Dany

  • Formatting a Date based on the user's Locale

    I'm having some trouble formatting a date based on the user's locale. I'm aware you can do something like this:
       public static String getAsString( Object dateObject, Locale locale ) {
          DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.MEDIUM, locale );
          return dateFormat.format( dateObject );
    However, this is returning something like Jan 21, 2009. I need 01/21/2009. Of course, if this was the UK locale it'd have to be 21/01/2009. Any help would be appreciated.

    another issue I'm running into is that when I'm logged in as a users' locale which uses '-' instead of '/' (i.e. 21-01-2009), I get a parse error. Can anyone provide any input? Thanks.
        * Parse a Date
        * @param dateString
        * @param locale
        * @return parsed Date
       public static Object parseDate( String dateString, Locale locale ) {
          DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.SHORT, locale );
          try {
             return dateFormat.parse( dateString );
          catch( Exception exception ) {
             throw new ExceptionUtl( UtlMessageHelper.getMessage( UtlMessageConstants.ERROR_FailedParseDateFromString, dateString ), exception );
        * Format the given value into a DateFormat
        * @param dateObject
        *           Object value to be formatted
        * @param locale
        *           Locale format to use
        * @return dateObject in SimpleDateFormat
       public static String formatDate( Object dateObject, Locale locale ) {
          DateFormat dateFormat = DateFormat.getDateInstance( DateFormat.SHORT, locale );
          if( dateFormat instanceof SimpleDateFormat ) {
             SimpleDateFormat simpleDateFormat = ( SimpleDateFormat )dateFormat;
             String pattern = simpleDateFormat.toPattern();
             if( !pattern.contains( "yyyy" ) ) {
                pattern = pattern.replace( "yy", "yyyy" );
             if( !pattern.contains( "dd" ) ) {
                pattern = pattern.replace( "d", "dd" );
             if( !pattern.contains( "MM" ) ) {
                pattern = pattern.replace( "M", "MM" );
             simpleDateFormat = new SimpleDateFormat( pattern );
             return simpleDateFormat.format( dateObject );
          return null;
       }

  • PJC Calendar setDate Wrong date format. Date change failed?

    Forms 10.1.2 using forms demos pjc code.
    The calendar pjc I added to my form works except I can't initialize it with a date. If I try to initialize a date it always produces 'Wrong date format. Date change failed.' error.
    In a post-query trigger, I initialize the calendar's date using:
    SET_CUSTOM_PROPERTY('PJC.CALENDAR',1,'setDate',to_char(:lead.date_received,'DD.MM.YYYY'));
    In the java console, this yields:
    Warning: Wrong date format. Date change failed.
    Warning: Wrong date format. Date change failed.
    I get the same result when using a hardcoded date like:
    SET_CUSTOM_PROPERTY('PJC.CALENDAR',1,'setDate','01.12.2006');
    What is the flaw in my incantation?

    Hello,
    This is the syntax used in the calendarpjc Forms demo:
        call the setDate method on the calendar PJC via the PL/SQL built in
        set_custom_item_property
        convert Oracle date to String recognised by Java
      procedure setDate(d in date) is
      begin
        set_custom_property(lGlobals.hCalendar,1,'setDate',to_char(d,'Mon DD, YYYY'));
      end;     Francois

Maybe you are looking for

  • Apple ID for Business Use

    We wanna roll-out 130 Iphones and 130 Ipads in our company, and there is one open point. Normally we use one Apple-ID for every Device, so we are saving the registration/administration of 130 Apple-IDs. We have the control of downloaded apps. Not eve

  • IPod is recognized by iTunes but songs won't show up on device

    I bought a brand new 32gb ipod touch 5th generation last weekend. I put about 8gb of music onto it. the music displayed under the "on my device" section of my ipod in itunes however when i disconnected my ipod the only songs on it were ones that were

  • Duplicates in the table

    hi, how to find the duplicates in the table in the below example Id     Empfirstname     Empfirstlastname     empdesig 1     Xyz     Abc     Software Engg 2     Xyz     Abc     Software Engg 3     Kkk     Ddd     Architect need query to display 1    

  • Adobe Reader for iOS

    I am new to apple operating systems and the iPad.  I down loaded the Adobe Reader app for iPad.  I cannot get a document to close so that I can view other documents on my iPad.  How do I close a document in Adobe Reader on the iPad?  Everytime I "clo

  • Video capture card - Geovision

    Guys, Someone has used Geovision capture cards? Working, ok ? Thanks Kalz