Question with SIMPLEDATE FORMAT in Java
How can I convert my Date field in the the format I want with Simple Date format.
Calendar cal1 = Calendar.getInstance(TimeZone.getDefault());
String DATE_FORMAT = "yyyy-MM-dd"; //
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
sdf.setTimeZone(TimeZone.getDefault());
String now = sdf.format(cal1.getTime());This code gives me the format I want, if I use a String , but I want to have this format in my DATE filed called START_DATE.
How can I do that?I am sorry, I am learning Java, so this might be very idiotic questions to ask..but if anybody can help me??
Thanks,
Edited by: ASH_2007 on Mar 18, 2008 10:30 AM
Yes, I know how to do that for a String.
But how do I do the same thing for Date fields?I believe I already mentioned that is non-sensical in java. There is no such thing as a "date field".
There is a Date object. And you use SimpleDateFormat to display it.
There are datatypes in a database that are associated with timestamp values. And I already explained to you that, as you have already found out, that datatype holds a timestamp. It does not hold a date (just a date) and it never will. It is not possible.
In terms of displaying (not storing) something in the database itself, not java, the way that you do that depends on the database.
But regardless of the database you MUST still do something in terms of DISPLAYING it to make a timestamp appear as display value that looks like a date.
Now exactly which parts of the above do you not understand????
Stop telling us what you want to do and start asking questions about what we said - because it is obvious that you are having problems with concepts, not code. And until you understand the comments you can't phrase a question correctly so that one can answer it with code.
Similar Messages
-
Error with "SimpleDate Format"
import java.util.*;
import java.util.Date;
import java.text.SimpleDateFormat.*;
class CmdLineApp
public static void main(String args[]){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
^ ^
1 2
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:SS ");
^ ^
3 4
Date now = new Date();
String dateString = dateFormat.format(now);
String timeString = timeFormat.format(now);
System.out.println(dateString);
System.out.println(timeString);
error 1-4>cannot recolve symbol.
can any one help mi explain.If you change import java.text.SimpleDateFormat.*; to import java.text.SimpleDateFormat;it should work.
-
Have 3 technical questions with QuickTime formats. Can you help?
Hi everyone,
I have 4 questions.
1)
If you were to rate the following file wrappers on a scale of 1 of 10 (10 offering the highest quality, 1 offering the lowest quality), what would you give the following file wrappers:
MPEG-1
MPEG-2
MPEG-4
MP4
.AVI
.MOV
.FLV
2)
Also, can you give a brief one sentence overview of how efficient each of the above file wrappers are. I've tried Wikipedia, but they don't really put it in laymans' terms.
3)
Which of the following file wrappers are lossy, and which are uncompressed???
MPEG-1
MPEG-2
.AVI
.MOV
MP4
MPEG-4
.FLV
4)
Is there an uncompressed file wrapper you can upload your video to?
Thanks,
rc444
please email me [email protected] as I need this information urgently for my school assignment.Wrong methodology for your questions.
It's what's inside the wrappers (codecs) that determine file size and quality.
All of those file extension use some level of compression and all are lossy.
The real answer is another question. "What is the format of your source video"? A DV digital camera would come into the computer at 13 GB's per hour and this .dv file can be edited using many different applications.
When you use these .dv files there is no loss in quality from your source. But at 13 GB's per hour the file size make an impractical delivery dilemma. You're forced, in most cases, to export to a delivery media (DVD, Web based files or CD's) and then you much choose other codecs and wrappers.
So now you must ask other questions. "How will my files be viewed"? "How small must the file size be based on the delivery media"? "How much compression and what codecs should I use"?
What do you have and where is it going to be viewed? -
Trying to teach self Java-question with arrays
I have a question with arrays. I have a simple inventory program that I am writing(very simple). I have declared and created my array. Is this the time I should build a new class outside of my main in order to hold my array? I am still trying to sort through classes and when to create them. My thought is that because it is a hierarchy I should have a new class. For example, Albums is at the top and then there are specific types of albums, like TributeAlbum, PremiereAlbum, etc. Do I need a class for each of these? When I create the class, do I use the same name as the array?
More info, just in case: My original class is AlbumInventory. I have created an array to hold 25 TributeAlbums which has 4 instance variables.
Question 2: Why can I not refer to an album variable like TributeAlbums[0].itemNumber?
Thanks in advance for your input.
DeniseI have a question with arrays. Okay.
I have a simple
inventory program that I am writing(very simple). I
have declared and created my array. Is this the time
I should build a new class outside of my main in
order to hold my array? In an OO language classes are usually a good idea.
I am still trying to sort
through classes and when to create them. My thought
is that because it is a hierarchy I should have a new
class.This sounds a bit confused. You should have a new class when it is appropriate to do so.
For example, Albums is at the top and then
there are specific types of albums, like
TributeAlbum, PremiereAlbum, etc. Do I need a class
for each of these? Not sure. Why is the type not an attribute of the Album class? This (attribute) seems at first glance to be the way to do it.
When I create the class, do I use
the same name as the array?
? I am going to say no but I'm not following what you are really asking here.
More info, just in case: My original class is
AlbumInventory. I have created an array to hold 25
TributeAlbums which has 4 instance variables.
Can you please post some of your actual formatted code? It would also be helpful to know what the attributes for an Album are as you have them. -
A big problem of Generate report with PDF format....Urgent
I want to generate a report with pdf format through one java file, it have two page 1)gen_report.jsp 2) report_gen.java , the compliation was failed. However, i don't what the problem is .... i hope anyone can help me as it is very argent for me ....Thanks a lot
1)gen_report.jsp
<table id="AutoNumber1">
<tr>
<td background="images/top5movie.png">
<p align="center"> </p>
</td>
</tr>
<tr>
<td >
<div align="center">
<table id="AutoNumber2" >
<form method="GET" action="../report_gen" name="report_gen" target="_blank" onSubmit="javascript:return checkr1(this)">
<tr>
<td ><b>Report Description:</b></td>
<td >This report is to show the top five popular movies in cinemix for a period </td>
</tr>
<tr>
<td><b>Data scope:</b></td>
<td >Start from
<input type="text" name="start" value="2003-1-1" >to
<input type="text" name="end" value="2006-1-1" ></td>
</tr>
<tr>
<td><b>Data processing:</b></td>
<td >Show
<select name="order_by">
<option value="desc" selected>top</option>
<option value="asc">bottom</option>
</select>
5 films</td>
</tr>
<tr>
<td> <p align="center">
<input type="submit" value="View_Report" name="subm">
</p></td>
</tr>
<input type="hidden" name="report" value="r1">
</form>
<form method="GET" action="../report_gen" name="report_gen" target="_blank" onSubmit="javascript:return checkr2(this)">
<input type="hidden" name="report" value="r2">
</form>
</table>
</div>
</td>
</tr>
</table>Then my java code is here
report_gen.java
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
// chart and pdf out
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.xy.*;
import org.jfree.data.xy.XYBarDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.statistics.SimpleHistogramDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.DefaultFontMapper;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.pdf.PdfPCell;
public class report_gen extends HttpServlet
private final String titles[] = {"Top Five popular movies ",
"Financial cirumstance of cinemas",
"Distribution of time segment",
"Distribution of favourite movie type"
private final String descs[] = {"This report is to show the top five popular movies in cinemix for a period ",
"This report is to show the financial circumstance of each cinema site ",
"This report is to analysis the customer when is the most visit time ",
"This report is to analysis the customer which type of movie do they watch the most"
private final String bigTitle = "Cinemix";
private final String driver = "org.gjt.mm.mysql.Driver";
private final String url= "jdbc:mysql://localhost:3306/cinemix";
private final String userID = "abc";
private final String passwd = "abc";
public void init(ServletConfig config) throws ServletException
super.init(config);
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
final int width = 550;
final int height = 200;
/ title font (centre and report title)
final Font fTitle0 = FontFactory.getFont("Helvetica", 42, Font.BOLD);
final Font fTitle1 = FontFactory.getFont("Helvetica", 30, Font.BOLD);
// centre name:
final String title0 = bigTitle;
// Default category for DefaultCategoryDataset
final String cat = "data";
Connection conn;
JFreeChart chart;
String title1 = "xyz Report";
String chartDesc = "description";
String notes[] = new String[4];
String chartTitle = "so bad this is title";
String chartXTitle = "this is x";
String chartYTitle = "this is y.";
String report = request.getParameter("report");
int max=-10000;
int min=10000;
int j=0;
// do some basic checking
if (report == null || report.equals(""))
report = "-1"; // this course unknow report error message
String start = request.getParameter("start");
String end = request.getParameter("end");
String order_by = request.getParameter("order_by"); // ToDo: check invalid string
int topN = 5;
String order = (order_by.equals("desc")) ? "Top" : "Last";
String inv[] = {"08:30", "09:30", "10:30", "11:30", "12:30", "11:30", "12:30", "13:30", "14:30", "15:30", "16:30", "17:30","18:30","19:30","20:30","21:30","22:30","23:30"};
int inv_val[] = new int[inv.length - 1];
try
Class.forName(driver).newInstance();
catch(Exception e)
printE("Cannot load mysql database driver!", response);
e.printStackTrace();
return;
try
conn = DriverManager.getConnection(url, userID, passwd);
if (report.equals("r1")) { // report 1
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
Statement stmt = conn.createStatement();
String sql = "select *,count(f.Name),f.Name from film f, filmDetail fd, ticket t where f.startDate > '" + start + "' and f.endDate < '" + end + "'and fd.filmID = f.filmID and fd.filmDetailID = t.filmDetailID group by f.name order by fd.filmDetailID asc limit '" +topN+"'";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next())
if (rs.getInt("fd.filmDetailID") > max) max = rs.getInt("fd.filmDetailID");
if (rs.getInt("fd.filmDetailID") < min) min = rs.getInt("fd.filmDetailID");
j++;
ataset.setValue(rs.getInt("fd.filmDetailID"), cat,rs.getString("f.Name"));
title1 = titles[0];
chartDesc = descs[0];
chartTitle = order + " " + topN + " popular movie";
chartYTitle = "Box Office record";
chartXTitle = "Film Name";
gender = " ";
chart = ChartFactory.createBarChart(chartTitle, chartXTitle, chartYTitle, dataset,PlotOrientation.VERTICAL, false, true, false);
else
print("Error: I don't inderstand your request!", response);
return;
catch (SQLException e)
printE("Cannot open database connection? <br>", response);
// printE(e.toString);
e.printStackTrace();
return;
response.setContentType("application/pdf");
Document document = new Document(PageSize.A4, 5, 5, 5, 5);
try
PdfWriter writer;
writer = PdfWriter.getInstance(document, response.getOutputStream());
HeaderFooter footer = new HeaderFooter(new Phrase("Page: "), true);
footer.setBorder(Rectangle.NO_BORDER);
document.setFooter(footer);
footer.setAlignment(Element.ALIGN_CENTER);
// step 3
document.open();
document.add(getHeader(title0, title1, start, end, gender, order, topN, chartDesc));
document.add(printChart(chart, writer));
document.add(getFooter(notes));
catch(DocumentException de)
de.printStackTrace();
// step 5
document.close();
return;
}// end doGet()
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
// processRequest(request, response);
/** Returns a short description of the servlet.
public String getServletInfo()
return "Generate reports for " + bigTitle;
/* To print en error and exit(?) */
private void printE(Object obj, HttpServletResponse response) throws IOException
response.setContentType("text/html");
PrintWriter out;
out = response.getWriter();
out.print(obj.toString());
out.close();
// To-Do: how to force exiting?
// create data chart
private PdfPTable getHeader(String title0, String title1, String start, String end, String sex, String order, int topN, String desc)
Font fTitle0 = FontFactory.getFont("Helvetica", 42, Font.BOLD);
Font fTitle1 = FontFactory.getFont("Helvetica", 24, Font.BOLD);
Font fTitle3 = FontFactory.getFont("Helvetica", 12, Font.BOLD);
Font fValue = FontFactory.getFont("Helvetica", 12, Font.UNDERLINE);
Paragraph parStartEnd = new Paragraph();
parStartEnd.add(new Phrase("Data start from: ", fTitle3));
parStartEnd.add(new Phrase(start, fValue));
parStartEnd.add(new Phrase(" to ", fTitle3));
parStartEnd.add(new Phrase(end, fValue));
Paragraph parGenerateDate = new Paragraph();
parGenerateDate.add(new Phrase("Report generated at: ", fTitle3));
parGenerateDate.add(new Phrase(new java.util.Date().toString(), fValue));
Paragraph parGender = new Paragraph();
parGender.add(new Phrase("Current show gender: ", fTitle3));
parGender.add(new Phrase(sex, fValue));
Paragraph parTopN = new Paragraph();
parTopN.add(new Phrase("Now is showing ", fTitle3));
parTopN.add(new Phrase(order, fValue));
parTopN.add(new Phrase(" ", fValue));
parTopN.add(new Phrase(new Integer(topN).toString(), fValue));
parTopN.add(new Phrase(" record(s)", fTitle3));
// Start main table
PdfPTable tblMain = new PdfPTable(1);
tblMain.getDefaultCell().setBorder(0);
// Print title
tblMain.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
tblMain.addCell(new Paragraph(title0, fTitle0));
tblMain.addCell(new Paragraph(title1, fTitle1));
tblMain.addCell("");
tblMain.addCell("");
tblMain.addCell("");
// Print headers data
//tblMain.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
//tblMain.addCell(parInvoiceNum);
//tblMain.addCell("");
tblMain.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
tblMain.addCell(parStartEnd);
tblMain.addCell("");
tblMain.addCell(parGenerateDate);
tblMain.addCell("");
if (sex != " ")
tblMain.addCell(parGender);
else if(order != null && topN > 0)
tblMain.addCell(parTopN);
else
tblMain.addCell(" \n");
tblMain.addCell("");
tblMain.setWidthPercentage(96);
tblMain.addCell(new Paragraph("Description of this report:", fTitle3));
tblMain.addCell(desc);
tblMain.addCell("\n");
// Finish main table
return tblMain;
// print a chart _directly_ to pdf and return a empty Pdftable...
public PdfPTable printChart(JFreeChart chart, PdfWriter writer)
PdfContentByte cb = writer.getDirectContent();
int width = 550;
int height = 450;
PdfTemplate tp = cb.createTemplate(width, height);
Graphics2D g2d = tp.createGraphics(width, height, new DefaultFontMapper());
Rectangle2D r2d = new Rectangle2D.Double(0, 0, width, height); //->,
chart.draw(g2d, r2d);
g2d.dispose();
cb.addTemplate(tp, 20, 170);
// quick method to push down the footer text
// the only things this method return
PdfPTable tblDownDown = new PdfPTable(1);
tblDownDown.getDefaultCell().setBorder(0);
tblDownDown.addCell(" \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n");
tblDownDown.addCell(" \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n");
tblDownDown.addCell(" \n \n \n \n \n \n");
return tblDownDown;
public PdfPTable getFooter(String notes[])
Font fNote = FontFactory.getFont("Helvetica", 14, Font.UNDERLINE);
Font fComment = FontFactory.getFont("Helvetica", 12, Font.ITALIC);
Font fTitle1 = FontFactory.getFont("Helvetica", 30, Font.ITALIC);
// Start footer table
PdfPTable tblFooter = new PdfPTable(1);
tblFooter.getDefaultCell().setBorder(0);
if (notes != null)
tblFooter.addCell(new Paragraph("Notes:", fNote));
tblFooter.addCell("");
tblFooter.addCell("");
tblFooter.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
for (int i=0;i<notes.length;i++)
if (notes[i] != null)
tblFooter.addCell(new Paragraph("" + (i+1) + ". " + notes[i] + "", fComment));
tblFooter.addCell("");
tblFooter.addCell("");
tblFooter.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
tblFooter.addCell(new Paragraph("- End of report -", fComment));
return tblFooter;
}Go to the cache directory and see if you can open the report directly from here (not in IE).
I have seen posts on problems with Acrobat Reader Plugin for IE (I believe it was version 6 of Reader). -
Converting files into pdf format in java
Hi all,
How can we convert a file into PDF format in java?My application does the
file upload, and I need the files to be converted into PDF format.
The uploaded file can be of any type. How can I do this?
Please give me some help.
Thanks and regards,
Sandeep.>
How can we convert a file into PDF format in java?My application does the
file upload, and I need the files to be converted into PDF format.
The uploaded file can be of any type. ...>1) Write a class that will intelligently render a file of any type..
2) ... (well, do '1' first, then after getting your Nobel prize for AI, come back and we'll talk)
>
Please give me some help.>Please review your requirement.
BTW
- PDF sucks. It is designed for printing, and I (for one) don't want to kill more trees, and have no printer.
- This subject (convert file to PDF) has been discussed on the forums a bazillion times. Did you search the forums before asking your two (very closely related) questions? -
Design View Not Displaying Pages with any Formatting
I asked this question in another thread and somebody locked it. The question is not answered. My Design view is not displaying my files with any formatting. I can view them in a browser, but not in Design view where I can see my work as I'm working. While I can upload files to the remote server (host provider) the links got screwed up so files on the remote server don't show any formatting either. Every link, thousands of links, are off by one word (folder) from where my site was residing on my hard drive. When I try to make a change to the links manually then I can no longer view them with any formatting in my own browser either.
On my local broswer on my PC the address line reads: http://localhost/folderNameIneedToDelete/filename.php
On the live website (for my homepage) the address line reads http://websiteName.com/folderNameIneedToDelete/index.html
(Here is the text from another thread that was improperly locked)
I just added a remote server to my site so I could begin uploading files to my host provider. When I saved the setup I saw a message popup about the cache changing. Now when I try to view a file in Dreamweaver in Design View it doesn't recognize any of the external style sheets. It displays with no formating.
I can still view the pages in a browser and they look appropriate, just not in Design View where I can continue working on the site as I've been doing.
How do I get Design View to display my pages properly again using the .css pages that apply to each page design?
Thanks,
RobertMurray, thanks for all your assistance.
Before I edit thousands of links again I want to confirm I've interpreted all your info correctly. If I setup everything as follows all my pages should work in Design View, browsers accessed from the "Preview/Debug in browser" icon in Dreamweaver and most importantly in a live environment at a host provider:
Site Setup
Site - Site Name: anything including spaces
Site - Local Site Folder: C:\wamp\www\rootfoldername\
Servers - Testing Server (Testing: checked)
Server Name: Testing Server
Connect Using: Local/Network
Server Folder: C:\wamp\www\rootfoldername\
Web URL: http://localhost/rootfoldername/
Remote Server - Maintain synmchronization information: checked
Remote Server - Automatically upload files to server on Save: unchecked
Remote Server - Enable file check-out: unchecked
Testing Server - Server Model: PHP My SQL
Version Control - Access: None
Advanced Settings - Local Info - Default Images Folder: C:\wamp\www\rootfoldername\_images\
Advanced Settings - Local Info - Links relative to: Document
Advanced Settings - Local Info - Web URL: http://sitename.com/
Advanced Settings - Local Info - Case-sensitive links checking: unchecked
Advanced Settings - Local Info - Enable Cache: checked
Advanced Settings - Cloaking - Enable Cloaking: checked
Cloak files ending with: unchecked
Advanced Settings - Design Notes - Maintain Design Notes: checked
Advanced Settings - Design Notes - Enable Upload Design Notes for Sharing: unchecked
Advanced Settings - File View Columns - Name: Built In - Show
Advanced Settings - File View Columns - Notes: Built In - Hide
Advanced Settings - File View Columns - Size: Built In - Show
Advanced Settings - File View Columns - Type: Built In - Show
Advanced Settings - File View Columns - Modified: Built In - Show
Advanced Settings - File View Columns - Checked Out By: Built In - Show
Advanced Settings - Contribute - Enable Contribute compatibility: unchecked
Advanced Settings - Templates - Don't rewrite relative document paths: checked
Advanced Settings - Spry - Asset Folder: C:\wamp\www\rootfoldername\SpryAssets\
Site File Structure - place files in the following folders:
C:\wamp\www\rootfoldername
webpages (html & php)
_images - [folder] (there are numerous image folders beginning with _images) containing .jpg and .png files
_includes - [folder] containing attached .php files for the header, navigation and footer attached to every page
_scripts - [folder] containing .js script files
_styles - [folder] containing .css files (external style sheets)
Connections - [folder] contains one php file (databasename.php)
SpryAssets - [folder] containing system generated .js files .css files and .gif files
ZendFramework - [folder] - I have no idea if the files in this folder are necesary and why it was placed here many months ago
** Links **
Remove the leading / from every link in every file
HTML5 shiv
using an external link will always reflect the latest changes(Question) - If I link to this .js file externally at google instead of linking to a current copy in my _script folder could future changes to this external .js file cause future problems with the webpages that have this file attached?
Remote Server
Setup a remote server using the ftp address settings provided by the host provider. (Question) Any settings defined for the future Remote Server (the first remote server was deleted when problems occured) will not cause any harm to anything involving the Testing Server such as viewing webpages in Design View, browsers accessed from the "Preview/Debug in browser" icon in Dreamweaver and will not cause any harm to any files eventually put to the host provider via that future Remote Server. Is that correct?
Murray, thanks again for your help,
Robert -
Schedule a job with email destination in BOXI R2 with email format as html
Hello Guys, would it to possible to schedule a job with email destination in BOXI R2 with email format as html? we are able to get it running with plain text email format. we use Java SDK to interface with BO Enterprise servers.
thanks for your thoughts,
VenkatHi
your job should SMOF_DOWNLOAD can bring new material master if you set up correctly.
as a smart method smof_download is the best way.
doble check your filter condition. it should work as you expected. because we dont involve in manual pulling...
check your variant once again. in vari table,
can you check r3ac1 - filter settings- source seetingsa--> source site nmae --> backendlogical system and filter sync..
br
Muthu -
Using different locale with date format
Hi guys,
I'm trying to print of the same date represented in its different locale but can't seem to get it right. I want the
dates and times to be represented appropriately (e.g., ?Feb? should be represented as ?f?vr.? in a
localized for France). I've also tried to use SimpleDateFormat but had no luck there either.
Locale[] locales = { new Locale("fr", "FR"), new Locale("zh", "CN"),
new Locale("it", "IT") };
for (int i = 0; i < locales.length; i++) {
//print date in the different locales
try {
changeLanuage(locales);
}catch(IOException e) {
System.out.println("ERROR:");
System.out.println()
public void changeLanuage(Local loc)
String dateString = "Sun Jan 27 01:56:00 GMT 2008"
// Get the default MEDIUM/MEDIUM DateFormat
String sdate = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date());
System.out.println(sdate);
try {
Date date;
date = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM,loc).parse(sdate);
String output;
output = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL,loc).format(date);
outputStream.write(output);
}catch(ParseException pe) {
System .out.println("ERROR: for lanuage could not parse date in string \"" +
dateString + "\"");
pe.printStackTrace();
Running the code, at the terminal i get the following output.Apr 3, 2008 5:00:03 PM
ERROR: for lanuage could not parse date in string "Mon Jun 12 10:50:00 BST 2006"
java.text.ParseException: Unparseable date: "Apr 3, 2008 5:00:03 PM"
at java.text.DateFormat.parse(DateFormat.java:335)
at readParser.changeLanuage(readParser.java:275)
at readParser.main(readParser.java:412)
If anyone can see what the problem is and how i can overcome it, i would greatly appreciate it if said so.
Thanks a Lotokay i've attempted date --> format but this getting the same exception throw at run time.
outputStream.write(present+" "+s.next()+"");
String dateString = "Mon Jun 12 10:50:00 BST 2006"
try {
//parse with default format
Date dtTmp = new SimpleDateFormat("MMM d, yyyy H:mm:ss a",loc).parse(dateString);
String strOutDt = new SimpleDateFormat("yyyy-MM-dd").format(dtTmp);
outputStream.write(strOutDt+"DONE");
}catch(ParseException pe) {
System .out.println("ERROR: for lanuage could not parse date in string \"" +
dateString + "\"");
pe.printStackTrace();
}Any suggestions/help would be great, thanks
ERROR: for lanuage could not parse date in string "Mon Jun 12 10:50:00 BST 2006"
java.text.ParseException: Unparseable date: "Mon Jun 12 10:50:00 BST 2006"
at java.text.DateFormat.parse(DateFormat.java:335)
at readParser.changeLanuage(readParser.java:261)
at readParser.main(readParser.java:397) -
SSRS is weird with date format
hello everyone,
I've got the weirdest problem.
At first it was the calendar in internet exporer showing the dutch format (which i want). After choosing the date i try to view the report. It wil tell me the date isnt in the right format. So for example. 22-02-2015 is wrong and should be 02-22-2015.
For the normal user this is annoying enough and i dont understand why the datepicker acts different than the report wants.
But now even stanger. I wanted to put a default date in my variable so i can test a bit easier. So i fill in 31-12-2015 and its accepted. But when i run the report, it tells me that the format is wrong. Soooooo. I changed the default value to 12-31-2015
(the english format)..... BUT!!! now the variable default value isnt accepted because its not in the right format.
Can someone please tell me how i can avoid format changes between browsers/platforms/computers or what so ever.
there is 1 format i want and nothing else. dd-MM-yyyy thats the way and nothing else.Hi Fibre1980,
As per my understanding, when you preview the report, you hope that the date is displayed in the format dd-MM-yyyy in calendar, right?
In Reporting Services, the format of date in calendar control depends on your client machines language and regional settings. If you want to display date in the format dd-MM-yyyy, you can get parameter values from a query, so that values get populated in a
dropdown list and displayed in your required format.
Here is a relevant thread you can reference:
https://social.technet.microsoft.com/Forums/en-US/6e719c7b-cfd5-4f0d-a530-f9710704446c/trouble-searching-with-date-format-usuk-formatting?forum=sqlreportingservices
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
If you have any feedback on our support, please click
here.
Wendy Fu
TechNet Community Support -
IS it possible to Format the data to CXML format in Java ?
Hi all,
I am new to Java programming. I am an SAP ABAP Developer and in my SAP CRM E-Commerce Web Shop coding, I have to do coding in Java.
My current requirement is that I have some set of data and I have to format this data to CXML format in Java. IS this possible?
Can I format the data to CXML format in Java? Are there standard API's to do this? Please let me know how should I procced with the coding?
Apart from formatting the output to CXML format, I have to also post this data to an external market place...How can I do this?
Please help me with relevant information. your help will be highly appreciated.
Regards,
Jessica SamIt should be possible to format the data, yes. If there's a "standard API" it should be one that comes out of that SAP CRM thing, so look there.
As for "posting to an external marketplace", that's far too vague a concept to be able to answer. You should start by getting the specs about "how to post" from that marketplace. -
HELP WITH TRANSFERING FILES BY JAVA
Hi everybody!
I'm making a chat with java (Sever and Client) using socket.
I'd like to know how could I transfer files in binary from this chat.
Could anyone help me??
Thanks in advance!There's nothing wrong at all about asking questions, or being new to Java. I certainly have a whole world of stuff to learn myself.
Nevertheless, the project you propose is not something a "new user" is typically going to be able to tackle fresh out of the gate. Spend some time with the tutorials, try some stuff out, and when your code breaks, bring it here for review.
Admittedly, I won't be able to help you much with Sockets... :o) -
Problem with background formatting in pivot table
Hello,
I have a problem with background formatting in pivot table. I can't change background (light blue rectangular in upper left corner). Do you have any idea how to do it?
Here is the link to the picture of the pivot table:
http://img163.imageshack.us/img163/110/unledfyq.png
I would be grateful for any help.
Regards,Hey,
Check this link once, you will need java script to acheive this:
http://everythingoracle.com/obieehdom.htm
scroll down to this topic: Parsing using HTML DOM
Please award points if helpful.
Thanks,
-Amith. -
How to parse string to date with defualt format?
is there any possibilities to parse a string to date if we don't specify the format in SDF?
In database we have different formats and we need to convert each one convert to date with common format(something like default), is there any possibilities to do in java?jwenting wrote:
Tolls wrote:
ColinAtWork wrote:
SumantK wrote:
In database we have different formats and we need to convert each one convert to date with common format(something like default), is there any possibilities to do in java?Why don't you store the date in the database as a DATE datatype then you can format anyway you like??Because some people seem to fear DATEs and prefer the supposed comforts of a VARCHAR2...after all, who knows what murky goings on occur with a DATE, but at least a VARCHAR2 is readable, or something like that anyway.Just because some people don't know how to work with DATE fields (which is the real reason for their "fear" doesn't mean you shouldn't use them.
They're the appopriate solution, so use it.Often but not always true.
For example neither MS SQL Server nor Oracle timestamp types will store the resolution capable with the Java Date type. So if one wants to maintain all of that resolution one requires either a varchar or two columns.
And although I haven't been able to confirm it (recently at least) at one time one of the Oracle drivers had a bug that a timestamp would wipe out following columns. For that one either one was left with having only a single timestamp as the last column or using a varchar. -
photoshop keeps crashing...saying an attempt was made to load a program with incorrect format. Can anyone help?
You can
Supply pertinent information for quicker answers
The more information you supply about your situation, the better equipped other community members will be to answer. Consider including the following in your question:
Adobe product and version number
Operating system and version number
The full text of any error message(s)
What you were doing when the problem occurred
Screenshots of the problem
Computer hardware, such as CPU; GPU; amount of RAM; etc.
Maybe you are looking for
-
Loop fields in an internal table
Dear experts, I have a scenario where I have an internal table (created in an end routine) c of felds that are both characteristics and key figures. I would like to do is to modify this table so that I keep the value of the charactersitics but I set
-
I have a code for sorting Radix Sort of type Interger but im not sure how to modify it to sort Characters. This is my code for type Int: import java.util.ArrayList; import java.util.Iterator; public class RadixSort { private static final int RADI
-
User-exit to craete text for sales order
Hi Expert, Can anyone tell me what's the user-exit to Populate texts in the Sales Order? sales order-> Header->Texts->RPD General Ledger Number
-
I got rid of my old iMac G5 computer which ran on Tiger, but not before I retained the hard drive, which was installed into a 'caddy'. There is a folder containing 20kb of damaged files. I wondered whether they were worth keeping, and if so, how do I
-
Hey folks Okay, my name is Lasse and I'm all new to iPhone app programming. I had luck making this REALLY simple app where my label gets the text of the pushed button. So.. I'm moving to the next step, and what I'm trying to create now, is my million