Print out a Date in a format I want

Now if I print out a Date object, I will get something like "Sat Jan 01 00:00:00 CST 2005", but what I want is "1/1/2005". I tried to use the get methods to get the month, day, and year so that I can put them in a format I want. However, all the get methods have been deprecated. What will be a possible(maybe easy as well?) way to do it? Thanks.

Something like:
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
public class Test {
    public static void main(String[] args) {
        DateFormat df = new SimpleDateFormat("d/M/yyyy");
        Date now = new Date();
        System.out.println(df.format(now));
        // new for Java 5.0 - almost the same format
        System.out.printf("%te/%<tm/%<tY%n", now);
}Note: If you're using Java 5.0, then you can use the new printf method for PrintWriters. However, this doesn't appear to have a formatting token for single digit months.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#dt
Cheers, Neil

Similar Messages

  • How to print out a date from the past

    I am trying to print out a date from the past but I cant seem to get It,
    Lets use for example Independece Day,
    How would you write the code in order to print out that exact date?

    Look at the
    [url=http://java.sun.com/javase/6/docs/api/index.html?
    java/util/Date.html]Date APIActually the Calendar class would be better to use, since you can set all the different fields from year to second, plus things like day of week, day of month, week of year, etc.
    too slow
    Message was edited by:
    hunter9000

  • How to print out the data from the file ?

    hi all,
    i have upload my file to here :
    [http://www.freefilehosting.net/ft-v052010-05-09 ]
    anyone can help me to print out the data from the file ?
    the content of the file should be like this :
    185.56.83.89 156.110.16.1 17 53037 53 72 1
    and for the seven column is
    srcIP dstIP prot srcPort dstPort octets packets

    hi all,
    i have try to do this
    public static void Readbinary() throws Exception
              String file = "D:\\05-09.190501+0800";
              DataInputStream dis = new DataInputStream(new FileInputStream(file));
              //but then how to read the content ??????can you give me more hint ?????
    i have find the netflow v5 structure by C
    struct NFHeaderV5{
    uint16_t version; // flow-export version number
    uint16_t count; // number of flow entries
    uint32_t sysUptime;
    uint32_t unix_secs;
    uint32_t unix_nsecs;
    uint32_t flow_sequence; // sequence number
    uint8_t engine_type; // no VIP = 0, VIP2 = 1
    uint8_t engine_id; // VIP2 slot number
    uint16_t reserved; // reserved1,2
    struct NFV5{ 
    ipv4addr_t srcaddr; // source IP address
    ipv4addr_t dstaddr; // destination IP address
    ipv4addr_t nexthop; // next hop router's IP address
    uint16_t input; // input interface index
    uint16_t output; // output interface index
    uint32_t pkts; // packets sent in duration
    uint32_t bytes; // octets sent in duration
    uint32_t first; // SysUptime at start of flow
    uint32_t last; // and of last packet of flow
    uint16_t srcport; // TCP/UDP source port number or equivalent
    uint16_t dstport; // TCP/UDP destination port number or equivalent
    uint8_t pad;
    uint8_t tcp_flags; // bitwise OR of all TCP flags in flow; 0x10
    // for non-TCP flows
    uint8_t prot; // IP protocol, e.g., 6=TCP, 17=UDP, ...
    uint8_t tos; // IP Type-of-Service
    uint16_t src_as; // originating AS of source address
    uint16_t dst_as; // originating AS of destination address
    uint8_t src_mask; // source address prefix mask bits
    uint8_t dst_mask; // destination address prefix mask bits
    uint16_t reserved;
    but how to translate the structure to java,then get the data from the file ?
    Edited by: 903893 on Dec 21, 2011 10:52 PM

  • Use same report to print out different data sources on the fly.

    Post Author: Lady101
    CA Forum: Data Connectivity and SQL
    We have 10 reports use diferent datasource( use views with different joint tables), but their print out format are identical. Is there a way to just use single report to run those 10 reports dynamically(the report can point to the right data source on the fly)? So that we can just change single report format when report format needs to be changed. Right now we have to change 10 reports format one by one.

    Another option would be to make a single pass in the Source Monitor and save a bunch of subclips. Here's a thread discussing keyboard workflows: Re: Question on making many Subclips in a fast way
    If you name highlights with one base name and lowlights with another, it would be easy to drop each batch into its own sequence.

  • Printing out a report in PDF format

    Hi,
    A colleague and myself have been converting an existing system for our customer from the traditional client/server architecture to a web-deployed system on 10g application server. I have been converting the reports from report 3.5 to reports 10g. The reports work fine but the problem we have is more to do with the printer than the reports itself.
    We have a requirement to print a barcode label (and some other text) to a DataMax printer. This printer seems to be quite fussy about the fonts that are used and essentially if you don't use the DataMax fonts the label comes out blank. I have managed however to produce reports as PDF and if I click the Printer button in the adobe control the report will print out as a bitmap image on the printer.
    Is there any way that I can produce the report as a PDF file and get it to print automatically ?

    Prohan,
    I have never been able to get PDF generation working from APEX. I have asked for some help on this forum, but go no responses. And I just won't spend the outrageous license fees for Oracle BI Publisher. But I have been successful in doing what need with some simple methods.
    1. If the email has some simple tables or formatted information from the database, use a PL/SQL procedure to generate an HTML formatted message and the utl_mail package to send the html formatted email. I use this for many customer and internal emails from both APEX and Oracle Forms applications.
    2 There is a stand-alone product PL/PDF (http://www.plpdf.com/) that allows you to generate PDF files directly from PL/SQL (again not APEX specific). I have demoed this product and it works pretty well, but I am not using it at this time because of the licensing that requires a fee for each database instance. It's not really that expensive, but it's more than I want to spend for the number of databases I have.
    3. If you have Acrobat Professional, you can export XML file from the database and create "mail merge" type PDF documents. But you can also do this with Word and a simple CSV or Excel output. Both of these are pretty easy from APEX. I have used both. I found the Work mail merge to be a little easier for end users to use, so this is my primary choice. But Acrobat Pro method also works well.
    If you are interested in any examples of these methods, let me know and I can send you something.
    Bill
    Bill

  • PO Print out and data issue in Aribic Language -AR

    Hi Guru,
    Thanks in advance..........
    I am facing problem in PO print out in AR language.
    When i print Compnay phone no. of PO in E language is printing correct like - +962 4400402
    But i select message type 'AR' then Company Phone No. printing like this - 96264420404+.
    Can any one can suggest we have any FM for converting telephone no. in AR language in same format - like +962 4400402.
    Regards
    Durgesh

    Hi,
    I think it is the issue of text wrapping.
    Are you using different text elements to display this text or same in both languages?
    Thanks,
    Archana

  • How do I get the system to print-out a date at the bottom of page?

    When I am at a website and ask for a print-out of the page -
    the current date and time of print-out no longer appears at the lower right corner of page.

    I have resolved the problem. I will not use your time attempting to explain the process of elimination. However, the end result---
    I had taken delivery of a new printer mid-January - it is a HP OfficeJet 6000 (E609) - I wondered if that might be the problem - since I could not ascertain exactly when the print-out problem had presented itself.
    O.K. I logged on to the system and brought up the "Google" page to ask for a print-out. I checked for a print - and when the print box appeared I checked on "properties". That showed - to the left: "General Everyday Printing" and over to the right: Page size "A4 210 x 297mm" also the option "letter 8.5" x 11" and Legal 8.5" x 14" - so, I changed it to ask for the "letter - 8.5" x 11" - then I checked to "print" - I believe it was the "OK" - and the "Google: page was printed intact - showing the data generally associated with the top of the page and the date/time at the lower right.
    I placed a telephone call the HP this morning to ask them about the "A4" option and was advised that it is a "standard size paper" - but could not explain under set of circumstances it would be applicable.
    Hopefully, this data will be helpful to someone - thank you very much for your assistance in this matter.

  • How to get pixel data in the format I want

    I'm writing a format plug-in and am having some difficulty getting the pixel data from photoshop in the format I want. From what I gather from the documentation in the SDK I need to specify the following to tell photoshop what format to deliver my pixels in:
    theRect
    loPlane
    hiPlane
    data
    colBytes
    rowBytes
    planeBytes
    planeMap
    I specify all of these appropriately for a 32 bit rgba8888 uncompresssed image and it works just fine... but ONLY if the image I load in the first place matches the format I am requesting. If the image I load is some other format, like a 256 color image with a palette, gFormatRecord->advanceState() just fails with a nebulous -30500 error code (formatBadParameters) instead of delivering pixel data.
    So my big question is this: Is Photoshop capable of doing the conversion and delivering the pixels to my format plug-in in my requested format? If it CAN do it, what might I be doing wrong? Please help! Thanks!!

    You noticed you can use the planeMap[] array to permute the channels. It's not so obvious that Photoshop should offer generalised bit depth/colour space/palette processing. It can be argued that's the role of the plugin itself: to mediate between Photoshop's native image data (which it does offer conveniently) and whatever arbitrary image format the user requires. At least, that's what most of
    my plugins do.
    Sure, there are a few obvious conversions, but you have to stop somewhere... Sooner or later you'll be implementing stuff on the Photoshop side that
    should be in a plugin. I don't have a big problem with the line drawn in the current API.

  • Printing out char data type - unexpected results

    Hi, I have just started programming, and my first language is Java. I'm using JDK6 update 1.
    Scenario 1: - When I do System.out.println(string1 + string2); where string1 and string2 are String variables, the result is as expected.
    Scenario 2: - When I do System.out.println(string1 + char1); where string1 is a String variable and char1 is a char variable, here also the result is as expected.
    Scenario 3: - But when I do System.out.println(char1 + char2) the output is some numbers (I got output 22 when char 1 is 'P' and char2 is 'I').
    Could someone please explain scenario number 3? How do I achieve a concatenated output of multiple chars?
    Thanks.

    Thanks, so if I understand this right, the + operator works for Strings but is not meant for chars. When I think about it now, it seems right, because a char will always ever be only one character, and never more than one character.

  • I sent an invoice from my iPad, it prints out 3 pages. I don't want the salutation printed out

    HP Officejet 6600 wireless e print & Apple iPad
    This question was solved.
    View Solution.

    Daizy, is the salutation page part of the invoice? And are you using AirPrint or ePrint to process this request?
    Generally speaking, your options are limited to what the application or service allows, and most do not allow you to only print selected pages. In this case, unless you work with a third party application which allows printing and has this feature, you will not be able to avoid printing the salutation.
    Let me know if this information is useful!

  • Equipment master data print out with general data and characterstics

    Hi,
    I need to take print out of equipment masters with general data and characterstics for around 300 masters at a time. Could any
    body sugget me the best way to take print out
    Regards,
    Srinivas Kasina

    I think I have not asked my query properly.
    For Maintenance Order, each order print out will be taken separately as a print out by using some template. Do you want the equipment master print out in that manner?
    Else you want the details of general tab & characteristics tab as columns like equipment list report?
    I hope my question is clear now.

  • GMT Calendar printing out time as IST

    Can anyone tell me why the following is happening please. I know there are always people asking about dates/times/timezones etc but i haven't seen anyone with this problem. so i'll ask it.....
    I'm creating a calendar with the GMT timezone. If the calendar is set to a date that is in daylight savings time it prints out the date with the timezone IST, but if the date is not in daylight savings time the date is GMT.
    How can i make it print the date with GMT ?
    I'm in Dublin, working on NT, with jdk1.3.1
    here's the code snippets if it helps:
    String time = "2003.08.13 AD 11:10:00.802 GMT";
    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd G HH:mm:ss.SSS z");
    Date temptime = sdf.parse(time);
    cal.setTime(temptime );
    temptime= cal.getTime();
    System.out.println("temptime = "+temptime);
    And here's the output:
    Wed Aug 13 12:10:00 IST 2003

    Hi "mazzam3",
    If you look at the source code for the "SimpleDateFormat" class, you will see that it uses the default time zone. So even though you have ensured that your "Calendar" instance is using the correct time zone, your "SimpleDateFormat" instance is not. What I usually do is set the default time zone for the JVM before I start working with dates and times -- that way I know that all date and time related classes are using the same time zone. So I guess in your case, I suggest setting the default time zone to GMT.
    Hope this helps.
    Good Luck,
    Avi.

  • Print out of Cheque

    Hi
    I am having problem in Cheque Printing. Kindly guide me in this regard. The steps involved in printing a cheque are as follows.
    1.   Posting an incoming invoice
    2.   Post the outgoing payment & take a printout of payment voucher (Currently done thru F.62)
    3.   After approval of the outgoing payment, the cheque has to be printed 
          separately.
    4.   I dont want to use the automatic payment program
    5.   I can't take a print out from FBZ5.
    6.  I want to print out cheque for a series of document numbers

    Hi Rajaram
    Please use Tcode F-58. See if it helps. Let me know if you need any other help.
    Please do award points if found useful.
    Regards,
    Karthik

  • How can I set the text feild in a form to print out the entire feild?

    Right now it's only printing out what shows in the box, I want the box to expand when printed and show all the text entered in the field, how can I set it to do that?

    I think that the font size has to be set in the form itself, not the FDF.

  • Need help for FM that converts RAW format data to xls format

    Hi all,
         I am able to get the data from the given spool number to be converted into 'RAW' format. I need to convert this data into Excel format nad want to send the mail as attachment.
         I want to know is there a Function Module that converts this RAW format data into the Excel format?
    regards,
    Brijesh Patel

    Hi,
    instead of that you can do this....
    once spool is generated you have spool number , using the spool number you can generate the excel file using the FM <b>RSPO_DOWNLOAD_SPOOLJOB</b>, pass the spool number, and filename as some.xls and then it will download it to xls file,
    Regads
    vijay

Maybe you are looking for

  • Date display in report

    Dear all, In SAP we have date in the dd.mm.yyyy format in the data whereas the Bi report displays date in the mm.dd.yyyy format. - how can this be corrected to display the date in dd.mm.yyyy format in BI. Regards, M.M

  • Error relinking during installation of 11.1.0.6

    Hello all, I'm trying to install Oracle 11.1.0.6 EE (software only) on an IBM machine running AIX 6.1.3. When I run the installer, it works fine until it gets to about 74% complete. Then, I get the following error: Exception Name: MakefileException E

  • The limitation of Virtual Memory

    hi all..... When exporting the huge data volume to excel, the process always terminated by time-out and dumps error. I read a lots of post and SAP notes. I found the root cause of lacking of memory. I have 8GB memory on OS.The limitation of virtual m

  • Buying additional iCloud storage with gift certificate

    I am not able to buy additional icloud storage using pre-loaded gift certificates in iTunes. Can onyone advise whether this is possible and if so how it is done?

  • Related to call

    When ever I have reset networking setting,some times I am unable call  to anybody it showing call failed