Save HTML and read in Android - android

I have created a function to generate receipt to save as text in the file.
but when I try to read that file, it shows me with HTML tags.
but when I open the text file from a phone using WPS office that doesn't show me HTML tags
this is when I open text file in phone:
this when I read file:
and this my code-:
File file = new File(Environment.getExternalStorageDirectory().toString());
file.mkdir();
if (file != null) {
Log.d("created", "notnull");
} else {
Log.d("created", "null");
}
File gpxfile = new File(file, "samples.txt");
FileWriter writer = null;
try {
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(gpxfile), Charset.forName("ASCII")));
//writer = new FileWriter(gpxfile);
//writer.write(billHTML());
out.write(billHTML());
//Log.d("writer", "" + billHTML());
//writer.close();
out.close();
**here i read file**
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(gpxfile), "ASCII"));
String sData;
while ((sData = in.readLine()) != null) {
System.out.println(sData);
}
Log.d("files", "" + in);
} catch (IOException e) {
e.printStackTrace();
}
this is genreate bill function.
public String billHTML() {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm");
Calendar c = Calendar.getInstance();
StringBuilder sb = new StringBuilder();
sb.append("<html>"
+ "<body>");
sb.append("<br>");
sb.append("<h1><br><center> Texto mi marca </<center></h1>");
sb.append("<h2><center> Texto mi marca </<center></h2>");
sb.append("<br>");
sb.append("<br>");
sb.append("<center>Fecha:  " + sdf.format(c.getTime()));
sb.append("<br>");
sb.append("<center>Factura:  " + sdf.format(c.getTime()));
sb.append("<br>");
sb.append("<center>Cllente al contado");
sb.append("<br>");
sb.append("<br>");
sb.append("<h2><center>-------------------------------------------</h2>");
sb.append("<br>");
sb.append("<br>");
sb.append("<br>");
sb.append("<br>");
sb.append("<br>");
sb.append("<table width=550>" +
" <tr>" +
" <th width='50%' align='left'> Description</th>" +
" <th width='10%' align='left'>Units</th>" +
" <th width='10%' align='right'>Price</th>" +
" </tr>");
for (int i = 0; i < Util.itemArrayList.size(); i++) {
sb.append("<tr>"
+ "<td>").append(Util.itemArrayList.get(i).description)
.append("</td>"
+ "<td align='left'>")
.append(Util.itemArrayList.get(i).units)
.append("</td>"
+ "<td align='right'>")
.append(Util.itemArrayList.get(i).price + "€")
.append("</td>"
+ "</tr>");
oldpay = Util.itemArrayList.get(i).price;
totalprice = totalprice + oldpay;
}
float basevalue = (float) (totalprice / 1.21);
float ivaValue = totalprice - basevalue;
sb.append("<tr>"
+ "<td>").append("-----------------------")
.append("</td>"
+ "<td align='right'>");
sb.append("<tr>"
+ "<td>")
.append("(Total)Base imponible")
.append("</td>"
+ "<td align='right'>")
.append("</td> "
+ "<td align='right'>")
.append(decimalFormat.format(basevalue) + "€")
.append("</td>"
+ "</tr>");
sb.append("<tr>"
+ "<td>")
.append("IVA (+21%)")
.append("</td>"
+ "<td align='right'>")
.append("</td> "
+ "<td align='right'>")
.append(decimalFormat.format(ivaValue) + "€")
.append("</td>"
+ "</tr>");
sb.append("<tr>" +
"<td>").append("==============================================").append("</td>" +
"<td>==========</td>" +
"<td>===========</td>");
sb.append("<tr>"
+ "<td>").
append("<b>Total </b>")
.append("</td>"
+ "<td align='right'>")
.append("</td> "
+ "<td align='right'>")
.append(decimalFormat.format(totalprice) + "€")
.append("</td>"
+ "</tr>");
sb.append("</table>");
System.out.print(sb.toString());
return sb.toString();
}

If you are using html markup to generate the receipt you probably should name the file something like sample.html instead of sample.txt this way in your computer will be opened by a internet browser instead of the notepad.
Probably WPS Office is smart enough to detect the html tags and display the file with the correct formatting.

Related

How to get the results from multiple servers in a function in Android

I'm installing Hybrid Ranking algorithm for Linked Data Extraction & Context on Android. Documents you can search Google for the keywords above.
And now I'm installing semantic similarity between two uri1 and uri2.
Input: two DBpedia URIs
Output: a value representing their similarity
private float similarity(String uri1, String uri2) {
float wikipedia = wikiS(uri1, uri2);
float abtract = abtractS(uri1, uri2);
float google = engineS(uri1, uri2, google);
float yahoo = engineS(uri1, uri2, yahoo);
float bing = engineS(uri1, uri2, bing);
float dilicious = engineS(uri1, uri2, dilicicous);
return wikipedia + abtract + google + yahoo + bing + dilicious;
}
And with each child function, I have to query data using SPARQL dbpedia, google, yahoo, bing, dilicious using provided API. The results obtained will be calculated to the parser and returns the corresponding float value.
Example for abtractS(uri1, uri2) below:
private float abstractS(String uri1, String uri2, final float wikiS){
String url = createUrlAbstractS(uri1, uri2);
StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
#Override
public void onResponse(String response) {
float abtractS = 0.0f;
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray data = jsonObject.getJSONObject("results").getJSONArray("bindings");
if(data.length() == 0){
showLogAndToast("No result");
}else{
JSONObject element = data.getJSONObject(0);
String label1 = element.getJSONObject("label1").getString("value");
String abtract1 = element.getJSONObject("abtract1").getString("value");
String label2 = element.getJSONObject("label2").getString("value");
String abtract2 = element.getJSONObject("abtract2").getString("value");
abtractS = calWordContained(label1, abtract2) + calWordContained(label2, abtract1) + wikiS;
//TODO: RESULT ABTRACTS HERE. How next?
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
Log.d(TAG, error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(request);
return 0.0f;//HERE: no results
}
private float calWordContained(String label, String abtract){
if(label.length() == 0 || abtract.length() == 0){
return 0.0f;
}
List<String> words = Arrays.asList(label.split(" "));
int count = 0;
float length = words.size();
for(int i = 0; i < length; i++){
if(abtract.toLowerCase().contains(words.get(i).toLowerCase())){
count++;
}
}
return (count/length);
}
public String createUrlAbstractS(String uri1, String uri2){
private String BASE_URL_DBPEDIA = "http://dbpedia.org/sparql?default-graph-uri=&query=";
String query = createQueryAbstractS(uri1, uri2);
String url = "";
try {
url = Config.BASE_URL_DBPEDIA + URLEncoder.encode(query, "UTF-8") + Config.RESULT_JSON_TYPE;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return url;
}
private String createQueryAbstractS(String uri1, String uri2){
String query = Config.PREFIX_DBPEDIA + " \n" +
"prefix dbpedia-owl: <http://dbpedia.org/ontology/>\n" +
"\n" +
"\n" +
"select ?label1, ?label2, ?abtract1, ?abtract2 where\n" +
"{\n" +
" {\n" +
" select *\n" +
" where{\n" +
" <" + uri1 + "> rdfs:label ?label1 ;\n" +
" dbpedia-owl:abstract ?abtract1 .\n" +
" FILTER langMatches(lang(?abtract1),'en') . \n" +
" FILTER langMatches(lang(?label1),'en') .\n" +
" }\n" +
" }\n" +
"\n" +
"\n" +
" {\n" +
" select *\n" +
" where{\n" +
" <" + uri2 + "> rdfs:label ?label2 ;\n" +
" dbpedia-owl:abstract ?abtract2 .\n" +
" FILTER langMatches(lang(?label2),'en') . \n" +
" FILTER langMatches(lang(?abtract2),'en') .\n" +
" }\n" +
" }\n" +
"}";
return query;
}
but how to do this on, I could not get the results I wanted in the similarity function (uri1, uri2). Therefore it will affect the results in different functions.
So I'm asking is: how can I get all the results of the function Wikis, abtractS, engine (google), engine (bing), engine (yahoo), engine (dilicious) in a simple way Best. I currently do on Android and data load times is very important.
Thank you very much!

SPP Android BT Connection quits after seconds (EEG readings)

I have created an app that receives data from a bt transmitter (Bluegiga). The readings are from EEG signals. The data rate is 1Khz (I have to admit it's high). Anyway, I acquire some data for some seconds and then the Bluetooth acts like there is no incoming data (which is not true). If I try to disconnect the Bluetooth using the app is clear that there is no more communication with the bt module at the EEG board since it doesn't respond to the desconnection (It has a led that indicates when is connected, and it doesn't turn of/on or anything).
If I decrease the data rate to (let's say 500hz) the app works ok, with some occasional 'quits', but tolerable. If I decrease it more the app works with no problems.
Of curse, by design, my app must work at 1Khz data rate so here is where the problem comes.
I have check some other post, trying to hit some kind of sns but nothing match my problem exactly (anyway I have tried to use the information on them but with no success obviously).
Sometimes I get this message, "dm_pm_timer expires", sometimes no (after the bt stops working).
Sadly there is no indication, Exception or message that can tell me what's going on.
Here is my Code for the BT reception Thread
class BluetoothReadThread extends Thread {
private final InputStream iStream;
private final OutputStream mmOutputStream;
private boolean continueReading = true;
public BluetoothReadThread() {
InputStream tmp = null;
OutputStream tmp2 = null;
try {
tmp = btSocket.getInputStream();
tmp2 = btSocket.getOutputStream();
} catch (IOException e) {
}
iStream = tmp;
mmOutputStream = tmp2;
}
#Override
public void run() {
int c;
int waitCount = 0;
while (continueReading) {
try {
if (iStream.available() > 0) {
waitCount = 0;
c = iStream.read();
readBuffer[readBufferPosition++] = c;
if (readBufferPosition == bitsExpected) {
if (bitsExpected == 22) {
ch1 = MultiplicationCombine(readBuffer[4], readBuffer[3]);
ch2 = MultiplicationCombine(readBuffer[6], readBuffer[5]);
ch3 = MultiplicationCombine(readBuffer[8], readBuffer[7]);
ch4 = MultiplicationCombine(readBuffer[10], readBuffer[9]);
ch5 = MultiplicationCombine(readBuffer[12], readBuffer[11]);
ch6 = MultiplicationCombine(readBuffer[14], readBuffer[13]);
ch7 = MultiplicationCombine(readBuffer[16], readBuffer[15]);
ch8 = MultiplicationCombine(readBuffer[18], readBuffer[17]);
} else {
ch1 = (int) filter_3((double)MultiplicationCombine(readBuffer[5], readBuffer[4], readBuffer[3]));
ch2 = (int) filter_4((double)MultiplicationCombine(readBuffer[8], readBuffer[7], readBuffer[6]));
ch3 = (int) filter_2((double)MultiplicationCombine(readBuffer[11], readBuffer[10], readBuffer[9]));
ch4 = (int) filter_2((double)MultiplicationCombine(readBuffer[14], readBuffer[13], readBuffer[12]));
ch5 = (int) filter_2((double)MultiplicationCombine(readBuffer[17], readBuffer[16], readBuffer[15]));
ch6 = (int) filter_2((double)MultiplicationCombine(readBuffer[20], readBuffer[19], readBuffer[18]));
ch7 = (int) filter_2((double)MultiplicationCombine(readBuffer[23], readBuffer[22], readBuffer[21]));
ch8 = (int) filter_2((double)MultiplicationCombine(readBuffer[26], readBuffer[25], readBuffer[24]));
}
Header_int = readBuffer[0];
PK_ID_int = readBuffer[1];
PK_Counter_int = readBuffer[2];
if (downsample++ == downsample_value) {
addEntry(ch1 / scaCh1, ch2 / scaCh2, ch3 / scaCh3, ch4 / scaCh4, ch5 / scaCh5, ch6 / scaCh6, ch7 / scaCh7, ch8 / scaCh8);
downsample = 0;
}
//ProgrNum,PacketType,Ch1,Ch2,Ch3,Ch4,Ch5,Ch6,Ch7,Ch8,MRK
if (write_open) {
osw.write(PK_Counter_int + "," + PK_ID_int + "," + ch1 + "," + ch2 + "," + ch3 + "," + ch4 + "," + ch5 + "," + ch6 + "," + ch7 + "," + ch8 + "," + bolOpenClose + "\n");
//osw.write(PK_Counter_int + "," + PK_ID_int + "," + ch1 + "," + ch2 + "," + ch3 + "," + ch4 + "," + ch5 + "," + ch6 + "," + ch7 + "," + ch8 + "," + "\n");
}
System.out.println(PK_Counter_int + "," + PK_ID_int + "," + ch1 + "," + ch2 + "," + ch3 + "," + ch4 + "," + ch5 + "," + ch6 + "," + ch7 + "," + ch8 + ", AV=" + iStream.available() );
mmOutputStream.write(valueSTR.getBytes());
// if(downsample++==14) { safe_copy(readBuffer); plot=true; downsample=0;}
readBufferPosition = 0;
try {
Thread.sleep(3);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
} catch (IOException e) {
System.out.println(e + "\nError sending data + :" + e);
// Bluetooth error! Stop reading.
//this.stopAndSendIntent();
}
}
}
/*
public void stopAndSendIntent() {
this.cancel();
Intent intent = new Intent();
intent.setAction(BLUETOOTH_ACTION_DONE_READING);
sendBroadcast(intent);
}
*/
public void cancel() {
System.out.println("-----Cancelling readThread!!");
try {
iStream.close();
} catch (IOException e) {
} catch (NullPointerException e) {
}
;
continueReading = false;
}
}
It works like this:
I read a received character (c=iStream.read()).
Then I copy this character to an int array until I reach the length of the packet (it can be 22 or 28 (bitsExpected)).
The following part is just filtering and plotting of the signal.
I have tried many other implementations but I get the same result.
Even if I eliminate the part of the filtering and plotting (just reading data) the problem persists.
If instead of working with array, I work with string, i.e, using append() (which should be the same?) I manage to get an working connection (no quits) but, as soon as I manipulate the program using the array everything is the same.
I'm stuck with this for 1 month already, so I will really appreciate any comments, past experience or suggestions.
Thanks in advance.
I just added this piece of code
if (PK_Counter_int % 100 == 0) mmOutputStream.write(startTring.getBytes());
and it works just fine so far.

Android get gmail email subject from notification

i would like to read the subject of a new received email (gmail) from an android notification.
I think i have to use a NotificationListenerService running in background, catch the notification of new email in real time, and read the subject from that.
But how can i read the subject or a part of body text? Is it possible?
Thank you very much.
Here is an example that catches notifications and puts them into a text file. I only made this for development purposes so I could see how each app populates the notifications but it should show you how to do it.
#Override
public void onNotificationPosted(StatusBarNotification sbn) {
super.onNotificationPosted(sbn);
new Store().execute(sbn);
}
private class Store extends AsyncTask<StatusBarNotification, Integer, Long> {
#Override
protected Long doInBackground(StatusBarNotification... params) {
String temp = "";
StatusBarNotification sbn = params[0];
Notification not = sbn.getNotification();
String pack = sbn.getPackageName();
// dump all the android notifications
if (pack.startsWith("com.android")) return null;
if (pack.startsWith("com.estrongs")) return null;
if (pack.startsWith("com.motorola")) return null;
count++;
if (not.category != null)
temp += "Category: " + not.category.toString() + "\n";
else
temp += "Category = null \n";
if (not.tickerText != null)
temp += "TickerText: " + not.tickerText.toString() + "\n";
else
temp += "TickerText = null \n";
temp += "Key: " + sbn.getKey() + "\n" + "ID: " + sbn.getId() + "\n";
SimpleDateFormat format = new SimpleDateFormat("DD-kk:mm:ss:SSS");
Long ptime = sbn.getPostTime();
temp += "Post time: " + format.format(ptime) + "\n";
Long nottime = not.when;
temp += "When: " + format.format(nottime) + "\n";
temp += "Extras..." + "\n";
Bundle bun = not.extras;
if (bun.getString(Notification.EXTRA_BIG_TEXT) != null)
temp += "BigText: " + bun.getString(Notification.EXTRA_BIG_TEXT).toString() + "\n";
else
temp += "BigText = null \n";
if (bun.getString(Notification.EXTRA_SUMMARY_TEXT) != null)
temp += "SummaryText: " + bun.getString(Notification.EXTRA_SUMMARY_TEXT).toString() + "\n";
else
temp += "SummaryText = null \n";
if (bun.getString(Notification.EXTRA_INFO_TEXT) != null)
temp += "InfoText: " + bun.getString(Notification.EXTRA_INFO_TEXT).toString() + "\n";
else
temp += "InfoText = null \n";
if (bun.getString(Notification.EXTRA_TEXT) != null)
temp += "Text: " + bun.getString(Notification.EXTRA_TEXT).toString() + "\n";
else
temp += "Text = null \n";
if (bun.getString(Notification.EXTRA_SUB_TEXT) != null)
temp += "SubText: " + bun.getString(Notification.EXTRA_SUB_TEXT).toString() + "\n";
else
temp += "SubText = null \n";
if (bun.getString(Notification.EXTRA_TITLE) != null)
temp += "Title:" + bun.getString(Notification.EXTRA_TITLE).toString() + "\n";
else
temp += "Title = null \n";
if (bun.getString(Notification.EXTRA_TITLE_BIG) != null)
temp += "Big Title:" + bun.getString(Notification.EXTRA_TITLE_BIG).toString() + "\n";
else
temp += "Big Title = null \n";
temp += "Fields... \n";
CharSequence[] lines = bun.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
if (lines != null) {
for (CharSequence line : lines) {
temp += "line: " + line.toString() + " \n";
}
} else {
temp += " no lines... \n";
}
file = new File(save, pack + count + ".txt");
try {
FileOutputStream fos = new FileOutputStream(file);
fos.write(temp.getBytes());
fos.close();
//Toast.makeText(this, "File written", Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
//Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
//Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
}
return null;
}
}
Notice I send the SBN to a background thread. The listener does not like much of anything in its thread. Also, the listener can be tricky with the debugger. I found that you need to disable the app in Android settings -> Sound & Notification -> Notification Access before you update the app. Then you can re-enable it once a package update is installed.
Hope that helps.

How to update server resource using WebDAV

I am writing an Android application in which I am using Jackrabbit WebDAV Library.
With help of this WebDAV library, I can download and upload files from and to server. This works as expected.
Now I want to get a byte array from file with specific offset from the server. For this what I have tried is:
byte buffer[] = null;
Log.d(TAG, "downloadBytes '" + fileUri + "' byteOffset '" + byteOffset + "' byteOffset '" + byteCount);
HttpClient httpClient = new HttpClient();
GetMethod httpMethod = new GetMethod(fileUri);
httpMethod.addRequestHeader("Accept-Ranges", "bytes");
int total = byteOffset + byteCount;
String bytesMessage = "bytes=" + byteOffset + "-" + total;
Log.d(TAG, "bytesMessage " + bytesMessage);
httpMethod.addRequestHeader("Range", bytesMessage);
httpMethod.addRequestHeader("Cache-Control", "no-cache, no-store");
httpClient.executeMethod(httpMethod);
This works as expected.
Similarly, I want to update file on server with byte array by specifying offset, but this doesn't appear to work; the server returns a 400 Bad Request error code.
byte buffer[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x50};
Log.d(TAG, "downloadBytes '" + fileUri + "' byteOffset '" + byteOffset + "' byteCount '" + byteCount);
HttpClient httpClient = new HttpClient();
PutMethod httpMethod = new PutMethod(fileUri);
httpMethod.addRequestHeader("Accept-Ranges", "bytes");
int total = byteOffset + byteCount;
String bytesMessage = "bytes=" + byteOffset + "-" + total;
Log.d(TAG, "bytesMessage " + bytesMessage);
httpMethod.addRequestHeader("Range", bytesMessage);
httpMethod.addRequestHeader("Cache-Control", "no-cache, no-store");
httpMethod.addRequestHeader("Overwrite", "T");
InputStream is = new ByteArrayInputStream(buffer);
RequestEntity requestEntity = new InputStreamRequestEntity(is, "text/plain");
httpMethod.setRequestEntity(requestEntity);
httpClient.executeMethod(httpMethod);
What am I missing in the request header?
Following are correct headers, using this I am able update webdav server resources with offset and byte length.
HttpClient httpClient = new HttpClient();
PutMethod httpMethod = new PutMethod(fileUri);
httpMethod.addRequestHeader("Accept-Ranges", "bytes");
int total = byteOffset + byteCount;
int range = total-1;
String rangeMessage = "bytes=" + byteOffset +"-" + range;
Log.d(TAG, "rangeMessage " + rangeMessage);
String lengthMessage = Integer.toString(byteCount);
String contentRangeMessage = "bytes " + byteOffset +"-" + range + "/*";
Log.d(TAG, "contentRangeMessage " + contentRangeMessage);
Log.d(TAG, "lengthMessage " + lengthMessage);
httpMethod.addRequestHeader("Content-Length", lengthMessage);
httpMethod.addRequestHeader("Content-Range", contentRangeMessage);
httpMethod.addRequestHeader("Cache-Control", "no-cache, no-store");
httpMethod.addRequestHeader("Overwrite", "T");

New line writing to a file

I am trying to write to a file the log of my application. I have created an method which appends a line to the end of the line.
public static void write2Log(String s){
StringBuilder contents = new StringBuilder();
File root = Environment.getExternalStorageDirectory();
File logFile = new File(root, "testWrite2file.log");
if (root.canWrite()){
try {
BufferedReader input = new BufferedReader(new FileReader(logFile));
String line = null;
while (( line = input.readLine()) != null){
contents.append(line);
// contents.append(System.getProperty("line.separator"));
}
input.close();
FileWriter logWriter = new FileWriter(logFile);
BufferedWriter out = new BufferedWriter(logWriter);
out.write(contents.toString()+"\r\n"+s);////<---HERE IS MY QUESTION
out.close();
}
catch (IOException e) {
Log.e("test", "Could not read/write file " + e.getMessage());
}
}
}
Everything works fine less the new character line.
I have tried using:
\r\n
System.getProperty("line.separator")
newline()
But i keep getting all in just one line :(
Any ideas?
Try this:
FileWriter logWriter = new FileWriter(logFile);
BufferedWriter out = new BufferedWriter(logWriter);
out.write(contents.toString());////<---HERE IS THE CHANGE
out.newLine();
out.write(s);
out.close();
Try this
public static boolean writeLog(String user , Exception exS) {
boolean d = false;
try {
File root = new File("TVS_log");
if (!root.exists()) {
root.mkdirs();
}
String name = user + "_" + TimeReporter.getTodayAll() + "_" + "log.txt" ;
System.out.println(name);
File text = new File(root , name);
if (!text.exists()) {
text.createNewFile();
}
String aggregate = "";
for (StackTraceElement element : exS.getStackTrace())
{
BufferedWriter writer = new BufferedWriter(new FileWriter(text)) ;
String message = exS.toString() + " - " + element.toString() + "\r\n" ;
System.out.println(exS.toString());
System.out.println(element.toString());
aggregate += message;
writer.write (aggregate);
writer.newLine();
writer.flush();
writer.close();
writer = null;
}
if(text.exists())
return text.length() > 0;
}catch(Exception ex){
ex.printStackTrace();
}
return d;
}
TimeReporter class and function
public class TimeReporter {
public static String getTodaysDate() {
String d = "";
final Calendar c = Calendar.getInstance();
d = String.format("%02d", c.get(Calendar.YEAR))
+ String.format("%02d", c.get(Calendar.MONTH) + 1)
+ String.format("%02d", c.get(Calendar.DAY_OF_MONTH));
return d;
}
public static String getTodaysTime() {
String d = "";
final Calendar c = Calendar.getInstance();
d = String.format("%02d", c.get(Calendar.HOUR_OF_DAY))
+ String.format("%02d", c.get(Calendar.MINUTE))
+ String.format("%02d", c.get(Calendar.SECOND));
return d;
}
public static String getTodayAll() {
return getTodaysDate() + "_" + getTodaysTime() ;
}
public static String getNow() {
final Calendar c = Calendar.getInstance();
String ld = c.get(Calendar.YEAR) + "/" + (c.get(Calendar.MONTH) + 1)
+ "/" + c.get(Calendar.DAY_OF_MONTH) + " "
+ String.format("%02d", c.get(Calendar.HOUR_OF_DAY)) + ":"
+ String.format("%02d", c.get(Calendar.MINUTE));
return ld;
}
}

Categories

Resources