Time formatting in jsp

Hi,
I am creating one portal component in JSPDynPage in which I
have to show auto generated date & time of xml news/article.
Date & Time is generated but it is in
MM/DD/YY - HH/MM/SS i.e. 10/23/2008 - 15:15:22 format .         But i want to display it as   10/23/2008  - 03:15 PM
I have to format the time in my JSPcode.
Anybody have any idea/code for this?

Hello Vishal,
Try out Java MessageFormat class. there you can format a Date Object as you like, i.e.:
import java.text.MessageFormat;
import java.util.Date;
public class Test {
     public static void main(String[] args) {
MessageFormat mf_MESSAGE_PRINT_DATE = new MessageFormat("This document was printed {0,date,MM/dd/yyyy}.");
String MESSAGE_PRINT_DATE = mf_MESSAGE_PRINT_DATE.format( new Object[] {new Date()});
System.out.println("--- "+MESSAGE_PRINT_DATE);
MessageFormat mf_MESSAGE_PRINT_DATE2 = new MessageFormat("u3053u306Eu30C9u30ADu30E5u30E1u30F3u30C8u306F{0,date,yyyy}u5E74{0,date,MM}u6708{0,date,dd}u65E5u306Bu5370u5237u3055u308Cu307Eu3057u305Fu3002");
String MESSAGE_PRINT_DATE2 = mf_MESSAGE_PRINT_DATE2.format( new Object[] {new Date()});
System.out.println("--- "+MESSAGE_PRINT_DATE2);
Best Regards, Thomas

Similar Messages

  • How to change the date time format in jsp

    Hello Sir,
    I am trying to convert the date from one format into another format.
    In SQLServer one fields type as datetime.
    when i tried to display it in jsp with String variable it shown like below,
    2006-08-16 09:11:23.0
    how to format this value as
    Wed, Aug 16, 2006 09:11 AM
    my code is
    java.text.SimpleDateFormat fmt= new java.text.SimpleDateFormat("EEE, MMM d, yyyy K:mm a ");
    fmt.format(string value fetch from dtabase field);
    Plz provide me the solution asap. very urgent request.
    Regards
    venki.

    Hello Sir,
    I am trying to convert the date from one format into
    another format.
    In SQLServer one fields type as datetime.
    when i tried to display it in jsp with String
    variable it shown like below,
    2006-08-16 09:11:23.0
    how to format this value as
    Wed, Aug 16, 2006 09:11 AM
    my code is
    java.text.SimpleDateFormat fmt= new
    java.text.SimpleDateFormat("EEE, MMM d, yyyy K:mm a
    fmt.format(string value fetch from dtabase field);
    Plz provide me the solution asap. very urgent
    request.
    Regards
    venki.Have a look in to the below code
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class DateFormatTest
    public static void main( String[] cmdArgs )
    throws Exception
    SimpleDateFormat sdfInput =
    new SimpleDateFormat( "yyyy-MM-dd" );
    SimpleDateFormat sdfOutput =
    new SimpleDateFormat ( "EEE, d MMM yyyy hh:mm aaa" ); //Change the patterns in to what ever u need
    String textDate = "2001-01-04";
    Date date = sdfInput.parse( textDate );
    System.out.println( sdfOutput.format( date ) );
    i will suggest u to look in to the API doc you will come to know lot many things.

  • How do I turn off automatic formatting of JSP pages

    Whenever I drop a component into my JSP from the component pallete JDeveloper automatically formats some "seemingly" random part of the page. This is very annoying since I spent time formatting the code the way I like it and then it's just re-written.
    I really want to turn this option off since it makes the pages almost unreadable, especially if you have a small print margin set.
    Help????

    I answered my own question. What I found happening was that every time I pasted into my JSP page the code seemed to be reformatted. What really was happening was that the indentation was being adjusted and the line formatted to fit within the specified right margin.
    If you go to Preferences|Code Editor and check off 'Adjust Indentation When Pasting' and 'Reformat Code Block When Pasting' this behavior goes away and the document stay's pretty much intact. It seems to be a good idea to increase the right margin also.
    The only formatting that occurs now is for the line you pasted and any lines below the pasted line are moved up under the pasted line.
    This change at least minimizes modifications so that if multiple developers make changes any code merges are reasonable.

  • How to show flexible date in a time component in JSP

    According to Steven Muench about How to handle Flexible Date Format
    on Feb 28,2001. I create the FlexiDate Domain and create a FlexiDate.class in the
    howto.common package. Then in Employees entity on the Attribute Setting page I select Hiredate attribute and change its datatype from Date to howto.common.FlexiDate.
    But in JSP when I edit a record the time component(LOV) only show YYYY-MM-DD and I can not select HH and MM. After select a day I want to append HH and MM by hand, but I can not enter HH and MM at all.
    Another problem: I need to calculate interval between two time columns and get hours. For example the interval between 2002-10-10 12:10 and 2002-10-11 14:10 is 26.
    I am pleading for help!

    To edit the time format, you need to:
    1. select the simple date formatter in the attribute's control hints and use a format string that includes a time format.
    2. Change your entity attribute to be of type 'timestamp' since the Date type doesn't allow editing the time portion of your field.

  • Day timer format calendar

    Does anyone know of software that can create what you can do with Calendar but in a week at a glance day timer format? IE - a 5 x 7 size with photos on the left and a week calendar on the right?
    Thanks!

    No I do not - but it sounds like a good suggestion for Apple - iPhoto menu ==> provide iPhoto feedback
    LN

  • During export from Discover to Excel, Time Format changes to Number Format

    Hi
    I have a seconds column which is of number datatype. But in my report, I am converting the number in *0HH:MI:SS* format. For example, I have *4952534 seconds*. So my report is showing *1375:42:14* which is a Time Format. It looks good when I view the data in Discoverer Viewer or Plus. But when I try to export the data to Excel, the time format gets converted to *4952534 seconds*, which is creating problems. So can you suggest on how can I preserve the formatting during export to excel from discoverer.
    Thanks
    Sachin

    Hi,
    Excel will not implement the 0HH:MI:SS data format, it just gets the field as a number. You will have to format the field into text using the calculation from my previous post.
    Rod West

  • Display value in hh:mm time format in SSRS Report

    Hi Everybody,
    I have an SSRS report where one of the column is sum of time values. When I do the summation, the values are coming in this format. In the last column the minute value is getting displayed more than 60. How can I format it to proper time format as hh:mm
    so that it displays as "08:15" . The expression which I am using is "  Sum(CDec(FormatNumber(Fields!Overtime_Hours.Value,2)),"Month"). Your help would be highly appreciated.
    January
    31/1/2014
    21/04/2014
    00:00
    07:75
    00:00
    07:75
    Thanks & Regards,
     RPC
    Regards RCP

    Hi RPC24,
    According to your description, you can calculate the correct value of time summation. Now you want to make the result into proper time format (hh:mm). Right?
    In this scenario, we can convert the time into string type, split the string based on delimiter ":" and convert each part into integer. Then do the calculation for each part and set the hour increase 1 every 60 minutes (we can adjust in expression).
    We have tested this case in our local environment. Here are screenshots for you reference:
    1. The report design looks like below:
    A: =Format(TimeValue(Fields!StartTime.Value.ToString),"hh:mm")
    B:=CStr(SUM(CInt(split(CStr(Format(TimeValue(Fields!StartTime.Value.ToString),"hh:mm")),":")(0)))+SUM(CInt(split(CStr(Format(TimeValue(Fields!StartTime.Value.ToString),"hh:mm")),":")(1)))\60)+":"+CStr(SUM(CInt(split(CStr(Format(TimeValue(Fields!StartTime.Value.ToString),"hh:mm")),":")(1)))
    Mod 60)
    Ps: In this sample, we used Time data type. You may need to do some modification in your expression based on the data type of the time data field.
    2. The result looks like below:
    Reference:
    Summing the Value of HH: MM: SS In SSRS
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • How to get system time format in time stamp

    Hello All,
    I have one problem regarding Time stamp. I want system time stamp format in Time control. If my system date/time format change then automatically my time stamp format should also change.If my system Time stamp format is hh:mm:ss AM/PM dd/mm/yy so in my LabVIEW time stamp format should also same. If System time stamp format hh:mm:ss AM/PM mm/dd/yyyy so in my LabVIEW time stamp format should also same.
    So Please help me its a very important for my automation application.
    Thank You.
    Vinal Gandhi
    Kudos are always Welcome.... :-)
    Vinal Gandhi, CLD
    Software Engineer

    Hi Vinal,
    have you tried the FormatDateTimeString function with a standard string indicator and the "%c" formatcode as described in the help instead of the generic timestamp indicator?
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • SPA9000 and Day time format

    Hello,
      in linksys administration guide for SPA9000 the Day time format is defined as Start time:   and End time.
    Is it possible to have more than one periods of Day time?
    For example lets say i want to define Day time beetween   08:00 and 13:00  and also day time 14:00 until 18:00. Is that possible?
    Thanks
    KM

    Hi Jeff,
      thanks for the reply. Tried your suggestion but it doesnt work. As soon as first end time kicks in thats it. Night time folks until the next day.
    KM

  • Time Format using text variable with replacement path

    Hi Friends,
                                 I've used "Text variable with replacement path" to make the column heading dynamic by replacing the values referring from "0calday"...
    everything is working fine, but here it is displaying the time format like
    YYYYMMDD (20030101), i want it to be displayed DDMMYYYY (01012003) in the column heading... how to make it possible?
    pls waiting for ur inputs, it's an urgent...
    Regards,
    Pattnaik

    Hi Satyakam,
    In the text variable properties make sure that in the replacment path you have chosen "Text" to appear date as per user setting . Other wise as in your case it must be set to "Key" which always shows in the format YYYYMMDD.
    Hope that helps.
    Regards
    Mr Kapadia

  • Data services with SQL Server 2008 and Invalid time format variable

    Hi all
    Recently we have switched from DI on SQL Server 2005, to DS(Date Services) on SQL Server 2008. However I have faced an odd error on the query that I was running successfully in DI.
    I validate my query output using a validation object to fill either Target table (if it passes), or the Target_Fail table (if it fails). Before sending data to the Target_Fail table, I map the columns using a query to the Target_Fail table. As I have a column called 'ETL_Load_Date' in that table, which I should fill it with a global variable called 'Load_Date'. I have set this global variable in the script at the very first beginning of the job. It is a data variable type:
    $Load_Date = to_char(sysdate(),'YYYY.MM.DD');
    When I assign this global variable to a datetime data type cloumn in my table and run the job using Data Services, I get this error:
    error message for operation <SQLExecute>: <[Microsoft][ODBC SQL Server Driver]Invalid time format>.
    However I didn't have this problem when I was running my job on the SQL Server 2005 using Data Integrator. The strange thing is that, when I debug this job, it runs completely successfully!!
    Could you please help me to fix this problem?
    Thanks for your help in advance.

    Thanks for your reply.
    The ETL_Date is a datetime column and the global variable is date data type. I have to use the to_char() function to be able to get just the date part of the current system datetime. Earlier I had tried date_part function but it returns int, which didn't work for me.
    I found what the issue was. I don't know why there were some little squares next to the name of the global variable which I had mapped to the ETL_Date in the query object!!! The format and everything was OK, as I had the same mapping in other tables that had worked successfully.
    When I deleted the column in the query object and added it again, my problem solved.

  • Help needed in Time format

    Hi
    I am using oracle 9i . Is there any option to change the time format ie. for eg: when iam inserting values (in the fields declared as timestamp) as '22-06-2005' it is showing errors but when changed to '22-jun-2005'it is working. In my case i want the values to be inserted in '22-06-2005' format.
    Also is it posssible to change dd-mm-yyyy format to yyyy-mm-dd.
    Thanking you in advance
    Dinny

    Hi
    When i create a having 'ALTER SESSION SET NLS_TIMESTAMP_FORMAT = ''YYYY.MM.DD HH24:MI:SS''' the time format is not getting intialized but when i run the stmt ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'yyyy-mm-dd'; the time format is getting initialized.
    SQL> CREATE OR REPLACE PROCEDURE set_date_format
    2 AS
    3 BEGIN
    4 Execute Immediate 'ALTER SESSION SET NLS_TIMESTAMP_FORMAT = ''YYYY.MM.DD HH24:MI:SS''';
    5 END set_date_format;
    6 /
    Procedure created.
    SQL> insert into sili values('2003-05-23');
    insert into sili values('2003-05-23')
    ERROR at line 1:
    ORA-01843: not a valid month
    SQL> insert into sili values('2003-jan-23');
    insert into sili values('2003-jan-23')
    ERROR at line 1:
    ORA-01843: not a valid month
    SQL> insert into sili values('23-jan-2005');
    1 row created.
    SQL> ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'yyyy-mm-dd';
    Session altered.
    SQL> insert into sili values('2003-05-23');
    1 row created.
    SQL> insert into sili values('2003-jan-23');
    1 row created.
    Thanks & regards
    Dinny

  • Specifying date time format in Finder

    How can I specify the date-time format in Finder for the "date-modified" and "date-created" columns in list view?
    About three years ago, I got a command line instruction to set these formats and I kept it at mm/dd/yy
    Then a couple days ago, I changed the date format in iStat menus and the date-time formats started acting weird. I want the dates to be like "07/08/05" (mm/dd/yy) and then the formats started changing to "November 07, 2008" (month/dd/yyyy). This change seemed to take effect any time I open the view options for a folder. Now I discovered that the date format change depending on the column width according to the format specified in system preferences, international, formats.
    Narrow column, short date format; a little wider to long format, with ellipses if the column is not wide enough; then full format.
    Does anyone know the command line to set the format to keep it to the one I want?

    this doesn't seem to be it. however I now like the way Finder does display dates -- format gets more compact as the width of the column decreases; although there still is some excess space left on the left -- perhaps for AM & PM which I don't use; I use a 24 hour time format instead.
    Happy New Year

  • Export in Time Format

    Hi Experts,
    Has anyone tried exporting the data in time format in BPC 7.0 M SP7?
    I have tried using ExportFormat=MultiWithHeader and I am getting all the dimensions and also proper time format. But I want only few dimensions in column.
    Say like if I have 8 diimensions then in the export file I want only 5 dimensions with data in time format.
    I have tried using MVAL also but it is throwing an error i.e. "Column reference exceeds".
    Please help me if anyone has done that.
    Regards
    Prity

    This is the FCP X forum - you should ask this question in the Final Cut Studio forum:
    https://discussions.apple.com/community/professional_applications/final_cut_stud io
    Having said that, the render time you mention doesn't sound unreasonable - what are you expecting?
    Render times depend on the amount of effects you have and the processor power of your Mac.
    Andy

  • When double to digital indicator set to display in time format... Value changes.

    Dear all,
    I am having trouble displaying the value I want. I have a double value say 320 sent to a digital indicator where I have edited the properites of it to display in a time format containing only minutes and seconds like so, '3:20'. Unfortunately it'll take the value and change it to a another value and display that. I do not know what the issue is. If anyone knows the solution... PLEASE post!
    There is an image attatched! 
    Thanks.
    Solved!
    Go to Solution.
    Attachments:
    img.JPG ‏24 KB

    I only believe so due to the fact that when I convert a value from time stamp to double such as 3:20 it gave me 320. So I thought that the reverse might be try. Should I just input the total amount of seconds and that will output the Minuteseconds that I want?
    Thanks for quick reply.

Maybe you are looking for