Convert java.util.Timestamp to a formatted java.util.date
Hi,
I am trying to convert a java.util.TimeStamp date from the DB to a formatted date object. So, how can I convert this TimeStamp into an hourly or daily format that will return me a java.util.Date object? I was trying to convert the TimeStamp using SimpleDateFormat and then parse out to a Date object, but this isn't working. This is what I need
TimeStamp converted to an "Hourly" date object --> 12:00pm
TimeStamp converted to a "Monthly" date object --> May
Hi,
I am trying to convert a java.util.TimeStamp date
from the DB to a formatted date object. I don't know what a "formatted date object" is. Do you mean a String?
So, how can
I convert this TimeStamp into an hourly or daily
format that will return me a java.util.Date object?I don't know what you mean when you say "...int an hourly or daily format that will return me a java.util.Date object". A format is a String, are you wanting to parse that into a java.util.Date object?
I was trying to convert the TimeStamp using
SimpleDateFormat and then parse out to a Date
object, but this isn't working. This is what I
need
TimeStamp converted to an "Hourly" date object -->
12:00pmThat's a String then?
A java.sql.Timestamp extends java.util.Date. So if you've a Timestamp, then you can use it as you would a java.util.Date. If you want a String, then as you say use SimpleDateFormat with the appropriate format string.
Good Luck
Lee
Similar Messages
-
Converting sql timestamp into a usable java format??
hi there.
does anyone know how to convert an sql timestamp into a usable java format? i have retrieved a timestamp from a mysql table in a jsp script and would like to convert it into the following format:
12:42pm | 08.07.02
as i understand it, i'll need to convert the timestamp into seconds since 1970 and then manipulate it as a calendar object? my first line is working, but i don't know what to do after...
java.sql.Timestamp sqlTimestamp = resultSet.getTimestamp("date_and_time");
next...?
any help would be much appreciated!!
thanks.please excuse my java sytnax ignorance, but i've tried a bunch of different syntax arrangements and can't figure out how to use the getTime() method. what comes after my first line there?
java.sql.Timestamp sqlTimestamp = resultSet.getTimestamp("date_and_time");
then something like:
long msec=date.getTime(sqlTimestamp);
but that doesn't seem to work...
thanks for any help! -
Convert java.sql.Timestamp to java.util.Calendar?
What's the best way to convert java.sql.Timestamp to java.util.Calendar?
Use Calendar's setTime(Date date) method.
java.sql.Timestamp extends java.util.Date.
-Roy -
I am coding a hoilday booking system using JSP to interact with a SQL Server database. On my JSP form which retrieves the information I have a little javascript pop-up date selector which appears to be returning a Timestamp value although the string value is visable in the entry field. Can I pass this to a javabean as a Timestamp, so far I have only passed strings? Also I then have to enter it in the database and so will need to convert it to an sql date type but I dont know which one is best. Previous to using the Timestamp returning calendar I was just entering text and parsing it to a util.Date in the bean and then converting that to an sql.Date for entry in the database. That worked fine but I want to use the pop-up any ideas? Also my bean won't compile if I declare java.util.Timestamp t;(cannot resolve symbol Timestamp !) even though I have imported util.
First of all, java.util.Timestamp does not exist. You probably need java.sql.Timestamp.
java.sql.Date and java.sql.Timestamp inherit from java.util.Date. So converting from java.sql.Date or java.sql.Timestamp to java.util.Date is easy, you don't have to do anything.
To convert a java.util.Date to a java.sql.Timestamp, do something like this:
import java.sql.Timestamp;
import java.util.Date;
Date date = new Date();
Timestamp ts = new Timestamp(date.getTime());Jesper -
I am trying to retrieve a list from coherence cache and when I try to test my cache I get the following exception
Exception in thread "main" (Wrapped) java.io.IOException: Deserialization failed, format CollectionFormat(public java.util.ArrayList())
at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:266)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ConverterFromBinary.convert(PartitionedCache.CDB:4)
at com.tangosol.util.ConverterCollections$ConverterMap.get(ConverterCollections.java:1655)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.get(PartitionedCache.CDB:1)
at com.tangosol.coherence.component.util.SafeNamedCache.get(SafeNamedCache.CDB:1)
at com.sesco.cohc.cohc_RegionalForecastedGen.getLatestDataForDataSource(cohc_RegionalForecastedGen.java:32)
at com.sesco.cohc.cohc_RegionalForecastedGen.main(cohc_RegionalForecastedGen.java:172)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.io.IOException: Deserialization failed, format CollectionFormat(public java.util.ArrayList())
at org.gridkit.coherence.utils.pof.ReflectionPofSerializer.internalDeserialize(ReflectionPofSerializer.java:105)
at org.gridkit.coherence.utils.pof.ReflectionPofSerializer.deserialize(ReflectionPofSerializer.java:92)
at com.tangosol.io.pof.PofBufferReader.readAsObject(PofBufferReader.java:3316)
at com.tangosol.io.pof.PofBufferReader.readObject(PofBufferReader.java:2604)
at com.tangosol.io.pof.ConfigurablePofContext.deserialize(ConfigurablePofContext.java:368)
at com.tangosol.util.ExternalizableHelper.deserializeInternal(ExternalizableHelper.java:2746)
at com.tangosol.util.ExternalizableHelper.fromBinary(ExternalizableHelper.java:262)
... 11 more
Caused by: java.io.IOException: Failed to deserialize java.util.ArrayList instance
at org.gridkit.coherence.utils.pof.ReflectionPofSerializer$CollectionSerializer.deserialize(ReflectionPofSerializer.java:317)
at org.gridkit.coherence.utils.pof.ReflectionPofSerializer.internalDeserialize(ReflectionPofSerializer.java:101)
... 17 more
Caused by: java.io.EOFException
at com.tangosol.io.AbstractByteArrayReadBuffer$ByteArrayBufferInput.readPackedInt(AbstractByteArrayReadBuffer.java:430)
at com.tangosol.io.pof.PofBufferReader$UserTypeReader.complete(PofBufferReader.java:3819)
at com.tangosol.io.pof.PofBufferReader.readCollection(PofBufferReader.java:2452)
at org.gridkit.coherence.utils.pof.ReflectionPofSerializer$CollectionSerializer.deserialize(ReflectionPofSerializer.java:306)
... 18 more
I am not sure why I am getting the error. Any help would be appreciatedYou were using the ReflectionPofSerializer coded by Alexey. If you are pretty sure that the object you retrieved was stored using the same serializer, might want to contact Alexey to see if he can help you out.
ReflectionPofSerializer - gridkit - ReflectionPofSerializer project page - A home for code misc usefull code related … -
Hi all,
I'm running into this odd behaviour.
I serialize java.util.Date objects to cache and when I read them back from cache, they appear to be java.sql.Timestamp types.
I've isolated a junit test for that.
Do you know why Coherence changes the type in the middle?
Regards
Harry.
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import com.tangosol.io.Serializer;
import com.tangosol.io.pof.ConfigurablePofContext;
import com.tangosol.util.ExternalizableHelper;
public class DatePofSerialTest {
@Test
public void testCobdate() throws Exception {
Date date=new Date();
Serializer serial = new ConfigurablePofContext();//"coherence-pof-config.xml");
Date date2=(Date)ExternalizableHelper.fromBinary(ExternalizableHelper.toBinary(date, serial), serial);
System.out.println(serial +" -- Date to serailize ["+ date.getClass() + "]");
System.out.println(serial +" -- Date from deserialize ["+ date2.getClass() + "]");
Assert.assertEquals(date, date2);/* Of course this passes, as both refer to the same time (long)*/
{code}
This gives as output
{code:title=output |borderStyle=solid}
log4j:WARN No appenders could be found for logger (Coherence).
log4j:WARN Please initialize the log4j system properly.
com.tangosol.io.pof.ConfigurablePofContext {location=coherence-pof-config.xml} -- Date to serailize [class java.util.Date]
com.tangosol.io.pof.ConfigurablePofContext {location=coherence-pof-config.xml} -- Date from deserialize [class java.sql.Timestamp]
{code}Hi Harry,
It looks like the same issue as ...
PofExtractor with java.util.Date results in ClassCastException
It was fixed in version 3.5.4.
Thanks -
Java Experts please help - SimpleDateFormat.format reduces date by a day !!
Hi,
I am facing a very weird problem with SimpleDateFormat class. The input Date to SimpleDateFormat.format method is getting reduced by ONE DAY. This problem is happening at random and is not reproducible at will. Any help/pointers to resolve this issue is very much appreciated !!.
Code is similar to the following code lines
input = "2003-11-01 00:00:00.000000000";
output = 31-Oct-2003 (strange !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!)
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormatSymbols;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Hashtable;
import java.util.Locale;
import java.util.TimeZone;
import java.util.SimpleTimeZone;
public class DateTester {
/** Default constructor for Util.
public DateTester() {
private static String replace(String pattern, String from, String to) {
return replace(pattern, from, to, null);
private static String replace(String pattern, String from, String to, String notFrom) {
StringBuffer sb = new StringBuffer();
boolean finished = false;
int index = pattern.indexOf(from);
if (index < 0) return pattern;
do {
if (notFrom == null ||
notFrom.length() + index > pattern.length() ||
!pattern.substring(index, index + notFrom.length()).equals(notFrom)) {
sb.append(pattern.substring(0, index));
sb.append(to);
sb.append(pattern.substring(index + from.length()));
finished = true;
} else index = pattern.indexOf(from, index + from.length());
while (!finished && index >= 0);
if (!finished) return pattern;
return sb.toString();
public static void main(String[] argv) {
String pattern = "DD-MON-YYYY";
System.out.println("original pattern =" + pattern);
pattern = replace(pattern, "FM", "");
pattern = replace(pattern, "AD", "G");
pattern = replace(pattern, "A.D.", "G");
pattern = replace(pattern, "BC", "G");
pattern = replace(pattern, "B.C.", "G");
pattern = replace(pattern, "AM", "a");
pattern = replace(pattern, "A.M.", "a");
pattern = replace(pattern, "PM", "a");
pattern = replace(pattern, "P.M.", "a");
pattern = pattern.replace('\"', '\t');
pattern = pattern.replace('\'', '\"');
pattern = pattern.replace('\t', '\'');
pattern = replace(pattern, "DDD", "DDD");
pattern = replace(pattern, "DAY", "dd");
pattern = replace(pattern, "DD", "dd", "DDD");
pattern = replace(pattern, "HH24", "HH");
pattern = replace(pattern, "HH12", "KK");
pattern = replace(pattern, "IW", "ww");
pattern = replace(pattern, "MI", "mm");
pattern = replace(pattern, "MM", "MM", "MMM");
pattern = replace(pattern, "MONTH", "MMMMM");
pattern = replace(pattern, "MON", "MMM");
pattern = replace(pattern, "SS", "ss");
pattern = replace(pattern, "WW", "ww");
pattern = replace(pattern, "W", "W");
pattern = replace(pattern, "YYYY", "yyyy");
pattern = replace(pattern, "YYY", "yyy");
pattern = replace(pattern, "YY", "yy");
pattern = replace(pattern, "Y", "y");
pattern = replace(pattern, "RRRR", "yyyy");
pattern = replace(pattern, "RRR", "yyy");
pattern = replace(pattern, "RR", "yy");
pattern = replace(pattern, "R", "y");
System.out.println("converted pattern =" + pattern);
String origDate = "2003-11-01 00:00:00.000000000";
System.out.println("original date =" + origDate);
Timestamp origTimeStamp = Timestamp.valueOf(origDate);
SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.getDefault());
sdf.setLenient(false);
String formattedDate = sdf.format((Date) origTimeStamp);
System.out.println("formatted date =" + formattedDate);
Thanks a lot for your time !Your code is too hard to read for me to look at it in great detail. When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.
However, I'm guessing it's a TimeZone issue. The midnight on 11/1 that you're setting is probably getting converted to GMT somewhere before the Date object is created. If you're in the U.S., then that's afternoon or evening on 10/31.
Try:
* Starting with a time that's later in the day on 11/1.
* Formatting your date to include time and timezone when you print it. (Just for testing--you can put it back once you understand what's going on
* Reading the Calendar, Timzone, Date, etc. APIs closely.
* Reading any tutorials or texts you can find on the subject.
* Writing a bunch of very small and simple tests to get an understanding of how this all fits together.
Date/Time/TZ handling in Java is kinda tricky. -
I want to unzip OpenOffice 1.0 files inside the OJVM but it fails into the native method java.util.zip.CRC32.updateBytes(CRC32.java).
The first execution of the code runs OK, but the second not.
After a long wait it shutdown the connection and the oracle trace file shows an stack trace like this:
*** 2003-04-18 11:31:31.926
*** SESSION ID:(17.97) 2003-04-18 11:31:31.926
java.lang.IllegalArgumentException
at java.util.zip.CRC32.updateBytes(CRC32.java)
at java.util.zip.CRC32.update(CRC32.java)
at java.util.zip.ZipInputStream.read(ZipInputStream.java)
at oracle.xml.parser.v2.XMLByteReader.fillByteBuffer(XMLByteReader.java:354)
at oracle.xml.parser.v2.XMLUTF8Reader.fillBuffer(XMLUTF8Reader.java:142)
at oracle.xml.parser.v2.XMLByteReader.saveBuffer(XMLByteReader.java:448)
at oracle.xml.parser.v2.XMLReader.fillBuffer(XMLReader.java:2012)
at oracle.xml.parser.v2.XMLReader.skipWhiteSpace(XMLReader.java:1800)
at oracle.xml.parser.v2.NonValidatingParser.parseMisc(NonValidatingParser.java:305)
at oracle.xml.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:274)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:254)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:225)
at com.prism.cms.frontend.EditPropertiesActions.processUpload(EditPropertiesActions.java:1901)
Exception signal: 11 (SIGSEGV), code: 1 (Address not mapped to object), addr: 0x6d3a74a0, PC: [0x40263600, eomake_reference_to_eobjec
t()+80]
Registers:
%eax: 0x54a54000 %ebx: 0x40429c20 %ecx: 0x54a546bf
%edx: 0x6d3a7478 %edi: 0x402b27d0 %esi: 0x45c718ac
%esp: 0xbfffbf20 %ebp: 0xbfffbf48 %eip: 0x40263600
%efl: 0x00010206
The code of the java method is:
public static void processUpload(String id_page, String longname,
String filename, String filetype,
String s00)
throws SQLException {
Integer p_id = new Integer(id_page);
String toSource;
XMLDocument doc = null;
DOMParser theParser = null;
InputStream XSLStream = null;
BufferedWriter out = null;
#sql { select path||name||'.html' into :toSource from pages where id_page=:p_id };
if ("Cancel".equalsIgnoreCase(s00)) {
Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
return;
if ("no-file".equals(filename) && "no-contenttpye".equals(filetype)) {
Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
return;
if ("xml".equalsIgnoreCase(filetype))
#sql { call CMSj.moveFromUpload(:filename,:p_id) };
else if ("sxw".equalsIgnoreCase(filetype)) {
XSLProcessor processor = new XSLProcessor();
XSLStylesheet theXSLStylesheet = null;
BLOB locator = null;
// open sxw file, it will be in zip format with a file named content.xml
// then convert content.xml to document-v10.dtd with an stylesheet
#sql { select blob_content into :locator from wpg_document where name = :filename for update };
ZipInputStream zin = new ZipInputStream(locator.binaryStreamValue());
ZipEntry entry;
try {
while((entry=zin.getNextEntry())!=null)
if ("content.xml".equalsIgnoreCase(entry.getName())) {
Integer newVersion;
CLOB dstDoc;
CMSDocURLStreamHandlerFactory.enableCMSDocURLs();
try {
URL inUrl = new URL("cms:/stylesheets/sxw2document-v10.xsl");
XSLStream = inUrl.openStream();
// Create the Stylesheet from the stream
theXSLStylesheet = processor.newXSLStylesheet(XSLStream);
// Stores the document processing it with the given stylesheet
theParser = new DOMParser();
theParser.setValidationMode(theParser.NONVALIDATING);
theParser.setBaseURL(new URL("cms:/dtd/"));
theParser.parse(zin);
doc = theParser.getDocument();
#sql { SELECT NVL(MAX(version),0)+1 INTO :newVersion FROM content
WHERE cn_id_page = :p_id };
#sql { INSERT INTO content( cn_id_page, version, owner, status, source_file,
file_size, content, created, modified, created_by,
modified_by)
VALUES ( :p_id, :newVersion, sys_context('cms_context','user_id'),
'Uploaded', :filename, 0 , EMPTY_CLOB(), SYSDATE, SYSDATE,
sys_context('cms_context','user_id'),
sys_context('cms_context','user_id')) };
#sql { SELECT content INTO :dstDoc FROM content
WHERE cn_id_page = :p_id AND version = :newVersion for update };
#sql { call DBMS_LOB.trim(:inout dstDoc,0) };
out = new BufferedWriter(dstDoc.getCharacterOutputStream(),dstDoc.getChunkSize());
processor.processXSL(theXSLStylesheet, doc, new PrintWriter(out));
#sql { delete from wpg_document where name=:filename };
} catch (SAXParseException spe) {
throw new SQLException("processUpload SAXParseException: "+xmlError(spe));
} catch (SAXException se) {
throw new SQLException("processUpload SAXException: "+se.getLocalizedMessage());
} catch (XSLException xsle) {
throw new SQLException("processUpload XSLException: "+xsle.getLocalizedMessage());
} finally {
if (XSLStream!=null)
XSLStream.close();
if (theParser!=null)
theParser = null;
if (out!=null) {
out.flush();
out.close();
zin.close();
} catch (IOException ioe) {
throw new SQLException("processUpload IOException: "+ioe.getLocalizedMessage());
} finally {
if (XSLStream!=null)
XSLStream = null;
if (out!=null)
out = null;
if (zin!=null)
zin = null;
Jxtp.redirecUrl("/dbprism/ldoc/live/edit.html?p_source="+toSource);
Basically it takes the content from a BLOB column of the wpg_document table, unzip it using java.util.zip package, look for the file content.xml and parse it using Oracle XML toolkit.
Using an open source utility which replace java.util.package (http://jazzlib.sourceforge.net/) it works perfect because is a pure java application.
Best regards, Marcelo.
PD: I am using Oracle 9.2.0.2 on Linux.The cause of errors was a dying Westen Digital drive, specially the 48G partition reserved only for $ORACLE_BASE (/dev/sdb3 mounted on /opt/oracle).
A simple quick scan of unmounted partition (badblocks -v /dev/sdb3) reported more than thousand new bad blocks (compared to the last scan six months ago). Although I strongly believe, specially in the case of WDC drives, that the best utility to "repair" bad blocks is the one that opens a window and prints the message: "Go to the nearest shop and buy a new drive", I was very curious to prove my suspicion just on this drive. After zero-filling the partition with dd, then formatting it (mke2fs -cc) and mounting again, the 11g installation and database creation (on the same partition) successfully completed, performing fast and smoothly. To make sure it was not a casual event, I repeated the installation once again with full success. The database itself is working fine (by now). Well, the whole procedure took me more than four hours, but I'm pretty satisfied. I learned once again - stay away from Western Digital. As Oracle cannot rely on dying drive, my friend is going tomorrow to spend a 150+ euro on two 250G Seagate Barracudas and replace both WDC drives, even though the first drive seems to be healthy.
In general there is no difference between loading correct data from good disk into bad memory and loading the incorrect data from dying disk into good memory. In both cases the pattern is damaged. For everyone who runs into the problem similar to this, and the cause cannot be easily determined, the rule of thumb must be:
1. test memory and, if it shows any error, check sockets and test memory modules individually
2. check disks for bad blocks regardless of the result of memory testing
Therefore I consider your answer being generally correct.
Regards
NJ -
How do I return a java.sql.Timestamp data type in a Web service?
I'm new to workshop and java. I'm creating a mini application to simulate a real work Web Service (development environment is on an intranet). I was able to completely simulate the Web Services minus all date values.
I'm using a standard weblogic workshop database controls that are feeding the various WebServices and their methods (Web services was generated from DB control). I get a java type not support error when I attempt to return a java.sql.Timestamp. I temporarily got around the problem by omitting all dates from the sql.
However, we are at the point where we need the complete record.
My two questions
1) What java data type do I convert the java.sql.Timestamp to
2) Where and how do I do it in workshop.
Thanks in advance
Derrick
Source view from workshop looks something like this.
public interface MyData extends DatabaseControl, com.bea.control.ControlExtension
static public class dbOverallRec
public String key;
public String field1;
public int field2;
public java.sql.Timestamp create_date
public dbOverallRec () {};
*@jc:sq; rowset-name="OverallRowSet" statement::
*select key, field1, field2 ,create_date from overall where key={KEY}::
dbOverallRec getOverallByKey(String Key);
* I had to omit the create_date to get it to workYou should try changing java.sql.Timestamp to java.util.Calendar.
java.util.Calendar maps to the dateTime type in XML Schema, and TIMESTAMP as a JDBC type.
Regards,
Mike Wooten -
RQL Error - JQuery Datepicker and java.sql.Timestamp
Hello everyone,
I am using JQuery Datepicker to select start and end date range.
Both start date and end date are successfully passed as like this. 10/01/2013 and 10/31/2013
It has java.sql.Timestamp mapping in both startDate and endDate.
Property name in component browser is transactionTimestamp.
It gives me following error when i passed both parameters.
<dsp:droplet name="/atg/dynamo/droplet/RQLQueryForEach">
<dsp:param name="repository" value="/atg/commerce/order/OrderRepository" />
<dsp:param name="itemDescriptor" value="inStorePaymentStatus" />
<dsp:param name="queryRQL" value="transactionTimestamp>=:startDate AND transactionTimestamp<:endDate" />
**** Error Wed Oct 02 16:07:21 IST 2013 1380710241490 /atg/dynamo/droplet/RQLQueryForEach unable to parse/execute query due to RepositoryException CONTAINER:atg.repository.RepositoryException; SOURCE:java.sql.SQLException: java.sql.SQLDataException: ORA-01843: not a valid month
It gives NO error when i passed single parameter.
<dsp:param name="queryRQL" value="transactionTimestamp>=:startDate"/>
can anyone suggest me a solution.
Thanks
saminda konkaduwaHi all,
Found the solution. We have to use parameter converter tools as well. that is the additional parameter called "date" where we passed date format.
<dsp:param name="startDate" param="10/12/2012" date="MM/dd/yyyy"/>
<dsp:param name="endDate" param="10/12/2015" date="MM/dd/yyyy"/>
Explanation :
JSP FILE ( testing.jsp)
=================
<dsp:page>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="merchant_portal_ajax_agent_report.js"></script>
<script type="text/javascript">
$(function() {
$("#startDate").datepicker();
$(function() {
$("#endDate").datepicker();
</script>
</head>
<body>
<table>
<tr>
<td>Start Date</td>
<td><input type="text" id="startDate" class="picker" name="sDate" /></td>
<td>End Date</td>
<td><input type="text" id="endDate" class="picker" name="sDate" /></td>
<td><input value="Find" type="submit" class="atg_button" onclick="loadAgentReport()" /></td>
</tr>
<tr>
<div id="agentReportTable"></div>
</tr>
</table>
</body>
</dsp:page>
JAVA SCRIPT FILE (merchant_portal_ajax_agent_report.js)
============================================
function loadAgentReport() {
var startDateValue = $("#startDate").val();
var endDateValue = $("#endDate").val();
$(document).ready(function() {
$.ajax({
type : "POST",
url : "merchant_portal_view_agent_report.jsp",
data : {
startDate : "" + startDateValue + "" , endDate : "" + endDateValue + ""
success : function(result) {
$("#agentReportTable").html("");
$("#agentReportTable").html(result);
JSP File ( This invoked by Jquery ) merchant_portal_view_agent_report.jsp
=======================================================
<dsp:page>
<dsp:droplet name="/atg/dynamo/droplet/RQLQueryForEach">
<dsp:param name="repository" value="/atg/commerce/order/OrderRepository" />
<dsp:param name="itemDescriptor" value="inStorePaymentStatus" />
<dsp:param name="queryRQL" value="agentId=:agentId AND transactionTimestamp>:startDate AND transactionTimestamp<:endDate" />
<dsp:oparam name="output">
<dsp:valueof param="element.transactionId"/> <dsp:valueof param="element.transactionStatus"/>
</br>
</dsp:oparam>
<dsp:oparam name="empty">
No data found
</dsp:oparam>
</dsp:droplet>
</dsp:page>
Thanks
saminda konkaduwa -
How to convert dd/mm/yy in ddmmyy in java
Can any one tell ,how to convert dd/mm/yy in ddmmyy in java
krishInda wrote:
Can any one tell ,how to convert dd/mm/yy in ddmmyy in javaI suppose, if you are sure of the validity of the string, you can just rebuild the string without the two forward slashes. Otherwise, see SimpleDateFormat for parsing and formating:
http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html -
Problem with converting html to pdf using LiveCycle ES Java API
I am using this code to convert html to pdf.
* 1. adobe-generatepdf-client.jar
* 2. adobe-livecycle-client.jar
* 3. adobe-usermanager-client.jar
* 4. adobe-utilities.jar
* 5. wlclient.jar
import java.io.File;
import java.util.Properties;
import com.adobe.idp.Document;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.livecycle.generatepdf.client.GeneratePdfServiceClient;
import com.adobe.livecycle.generatepdf.client.HtmlToPdfResult;
public class ConvertHTML {
public static void main(String[] args)
try{
//Set connection properties required to invoke LiveCycle ES
Properties connectionProps = new Properties();
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "t3://localhost:7001");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,Service ClientFactoryProperties.DSC_EJB_PROTOCOL);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "WebLogic");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
//Create a ServiceClientFactory instance
ServiceClientFactory factory = ServiceClientFactory.createInstance(connectionProps);
//Create a GeneratePdfServiceClient object
GeneratePdfServiceClient pdfGenClient = new GeneratePdfServiceClient(factory);
//Get an HTML document to convert to a PDF document a
String inputFileName = "http://www.adobe.com";
//String inputFileName = "C:\\Documents and Settings\\venkat\\Desktop\\Adobe.htm";
String securitySettings = "No Security";
String fileTypeSettings = "Standard";
System.out.println("one");
//Convert HTML content to a PDF document
HtmlToPdfResult result = pdfGenClient.htmlToPDF2(inputFileName, fileTypeSettings, securitySettings, null, null);
System.out.println("two");
//Get the newly created document
Document createdDocument = result.getCreatedDocument();
//Save the PDF document as a PDF file
createdDocument.copyToFile(new File("C:\\test.pdf"));
catch (Exception e) {
System.out.println("Error OCCURRED: " + e.getMessage());
e.printStackTrace();
I can able to compile this class but while running i am getting error like below.
Error OCCURRED: Internal error.
ALC-DSC-000-000: com.adobe.idp.dsc.DSCRuntimeException: Internal error.
at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.doSend(EjbMessageDispatcher.java
:160)
at com.adobe.idp.dsc.provider.impl.base.AbstractMessageDispatcher.send(AbstractMessageDispat
cher.java:57)
at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:208)
at com.adobe.livecycle.generatepdf.client.GeneratePdfServiceClient.htmlToPDF2(GeneratePdfSer
viceClient.java:666)
at ConvertHTML.main(ConvertHTML.java:84)
Caused by: java.rmi.RemoteException: Remote EJBObject lookup failed for 'ejb/Invocation'; nested exc
eption is:
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 203 completed: No
at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initialise(EjbMessageDispatcher.
java:101)
at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.doSend(EjbMessageDispatcher.java
:130)
... 4 more
Caused by: org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 203 completed: No
at com.sun.corba.se.impl.logging.ORBUtilSystemException.writeErrorSend(Unknown Source)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.writeErrorSend(Unknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.writeLock(Unknown Source)
at com.sun.corba.se.impl.encoding.BufferManagerWriteStream.sendFragment(Unknown Source)
at com.sun.corba.se.impl.encoding.BufferManagerWriteStream.sendMessage(Unknown Source)
at com.sun.corba.se.impl.encoding.CDROutputObject.finishSendingMessage(Unknown Source)
at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.finishSendingRequest(Unknown Sour
ce)
at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete1(Unkno
wn Source)
at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(Unknow
n Source)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.invoke(Unknown Source)
at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.is_a(Unknown Source)
at org.omg.CORBA.portable.ObjectImpl._is_a(Unknown Source)
at weblogic.corba.j2ee.naming.Utils.narrowContext(Utils.java:126)
at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFact
oryImpl.java:94)
at weblogic.corba.j2ee.naming.InitialContextFactoryImpl.getInitialContext(InitialContextFact
oryImpl.java:31)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:41)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initJndiContext(EjbMessageDispat
cher.java:213)
at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.getJndiContext(EjbMessageDispatc
her.java:226)
at com.adobe.idp.dsc.provider.impl.ejb.EjbMessageDispatcher.initialise(EjbMessageDispatcher.
java:87)
... 5 more
can u plz give me some way to do the convertion.Yes Sir.....Thanks for ur suggestion.....
But i didn't find exact solution..well..yes i found some but not exactly there were not in the way i required...I jus need to convert HTML to PDF using iText API for java.....I already used some classes in that like HTMLParser.....etc..
So Any thing else...Any one...Sure can help me in this................ -
Convert tline into pdf file document in Java
Dear ALL,
I built a RFC FM to convert smartform into tline which including PDF data.
the Code:
Converting to PDF Format
DATA l_lines TYPE TABLE OF tline WITH HEADER LINE.
* DATA l_lines1 TYPE TABLE OF solix_tab WITH HEADER LINE.
DATA l_docs TYPE TABLE OF docs.
DATA len TYPE i.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = len
TABLES
otf = job_output_info-otfdata[]
doctab_archive = l_docs[]
lines = l_lines[] "this inner table include pdf file data
EXCEPTIONS
err_conv_not_possible? = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
*CALL METHOD cl_gui_frontend_services=>gui_download
* EXPORTING
* bin_filesize = len
* filename = 'c:\pdf.pdf'
* filetype = 'BIN'
* CHANGING
* data_tab = l_lines[]"i_objbin[]
* EXCEPTIONS
* OTHERS = 1.
"If i want to save it in my PC ,call this FM CALL METHOD cl_gui_frontend_services=>gui_download.
But i dont want to do it.I want to pass the parameter l_lines[] to java(web) by RFC, and convert to pdf file and show in java(web).
thanks
FreddyHi,
Update:
I have tested this and here is some code:
SAP:(I got the OTF from CALL FUNCTION 'PRINT_TEXT')
FORM get_pdf_data
USING
tdname TYPE thead-tdname
CHANGING
it_tline TYPE text_line_tab
bin_file TYPE xstring .
DATA: st_thead TYPE thead .
DATA: it_lines TYPE tline_tab .
st_thead-tdobject = 'TEXT' .
st_thead-tdname = tdname .
st_thead-tdid = 'ST' .
st_thead-tdspras = 'E' .
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = st_thead-tdid
language = st_thead-tdspras
name = st_thead-tdname
object = st_thead-tdobject
IMPORTING
header = st_thead
TABLES
lines = it_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
DATA: it_otfdata TYPE otf_t_itcoo .
DATA: st_options TYPE itcpo.
st_options-tdgetotf = abap_true .
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
dialog = abap_false
header = st_thead
OPTIONS = st_options
TABLES
lines = it_lines
otfdata = it_otfdata
EXCEPTIONS
canceled = 1
device = 2
form = 3
OPTIONS = 4
unclosed = 5
unknown = 6
format = 7
textformat = 8
communication = 9
bad_pageformat_for_print = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
DATA: it_otfdata_m TYPE otf_t_itcoo .
* "Merge pdf output demo"
APPEND LINES OF it_otfdata TO it_otfdata_m .
* DATA: bin_file TYPE xstring .
DATA: it_lines_dummy TYPE tline_tab .
DATA: bin_filesize TYPE i .
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_file = bin_file
bin_filesize = bin_filesize
TABLES
otf = it_otfdata_m
lines = it_lines_dummy
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
ENDFORM. " GET_PDF_DATA
Java:
final byte[] byteArray = function.getExportParameterList().getByteArray("BIN_FILE");
final Path path = Paths.get("My.pdf");
Files.write(path, byteArray, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
regards.
Another update:
Using in HttpServlet:
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoRepository;
import com.sap.conn.jco.ext.Environment;
import destinations.MyDestination;
public class MyServlet extends HttpServlet {
@Override
protected void doGet(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws ServletException, IOException {
httpServletResponse.setContentType("application/pdf");
httpServletResponse.setStatus(HttpServletResponse.SC_OK);
final ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream();
servletOutputStream.write(getPDF());
servletOutputStream.flush();
servletOutputStream.close();
private byte[] getPDF() {
try {
Environment.registerDestinationDataProvider(new MyDestination());
final JCoDestination destination = JCoDestinationManager.getDestination(destinations.Id.sapdev2.name());
final JCoRepository repository = destination.getRepository();
final JCoFunction function = repository.getFunction("Y_R_EITAN_TESTS_03");
function.execute(destination);
final byte[] byteArray = function.getExportParameterList().getByteArray("BIN_FILE");
return byteArray;
} catch (final JCoException exception) {
exception.printStackTrace();
return null; -
Java.sql.Timestamp: does not have a no-arg default constructor ERROR
Hi,
I am using jaxws(jwsdp2.0) and when i use the apt tool I get this error because I use java.sql.Timestamp as one of the fields in a class. What is the workaround for this problem? Any help is appreciated.
Thanks,
VijayI just replaced java.sql.Timestamp to java.util.Date for this to work.
Any other workaround is welcome.
Vijay -
How can I create ajava.sql.Timestamp with the value -4712.01.01?
Trying Timestamp timestamp = new Timestamp( -210863523208000l );leads to the date 4713-02-08 00:06:32.0.
Or what is the minimal java.sql.timestamp value in Java?
Edited by: bejq on 17.03.2009 08:56bejq wrote:
Thanks for your quick answer.
Yes it is 1st January 4712 BC.
Timestamp timestamp = new Timestamp( -4712, 1, 1, 0, 0, 0, 000 );//deprecated Method
System.out.println( timestamp ); // returns 2813-02-01 00:00:00.0
System.out.println( timestamp.getTime() );// returns -150904688400000Thats not what I want.You have lost me then. Unless of course you want to use SimpleDateFormat with an appropriate TZ to parse the date to a java.util.Date and then construct a java.sql.Timestamp from the java.util.Date using the java.util.Date#getTime() method to construct the java.sql.Timestamp .
Edited by: sabre150 on Mar 17, 2009 10:41 AM
Maybe you are looking for
-
Nvidia optimus technology and arch, discrete card failed , 650M
Dell 7720 SE with nvidia gt 650m ddr5 2 weeks ago when I finally had time to play I've notice that my graphic card is no usable... I've just run pacman -Syu (full sys upgrade including kernel(3.10.7-1) nvidia blobs(325) and bbswitch) and still doesn'
-
I try play this quicktime movie file and then it says i do not have the required codec and the only thing i can press is "ok" or "tell me more" and then it just brings me to this page, it says nothing about how to obtain this certain codec. I need th
-
Hello, I've been wondering about this for a while and now that iOS 8 made some leaps with the keyboard, hopefully what I want is now possible. Fair warning this is rather specific. The default quote marks on iOS look like this: "quote." But if possib
-
Need help in OID user Trusted recon
Hi all, I am using oim9.1.0.1,oid 9.0.4.7. When i run the OID user trusted recon it is bringing users based on pagesize.The problem is if i set the page size as 100 then it brought 98 users where as i have 30000 users in my OID.When i set the page si
-
I'm trying to generate a form in BPM 11g using jDeveloper 11.1.1.4 and it locks up ALL THE TIME!! I've literally had to quit jDev eight times this morning, and I still don't have the form generated. jDev consistently sucks up 99-180% CPU time and ove