将日历对象设为字符串
我是新手,所以要温柔!
我正在尝试解析一个日历对象,该对象已增加 1 个月为字符串,以便我可以将其添加到字符串生成器并最终使用蓝牙打印机打印它。
这是我当前正在尝试使用的代码;
else if
(Res.equals("&EXCLEND")){
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, 1);
SimpleDateFormat excluEnd = new SimpleDateFormat("DD-MM-YYYY-hh-mm");
String EndDateString ="";
// cal.DAY_OF_MONTH.toString() + "/" + cal.getDisplayName(Calendar.MONTH, cal.SHORT, cal.Locale.UK);
//Toast.makeText(getBaseContext(), EndDateString, Toast.LENGTH_LONG).show();
try {
BufferedReader br = new BufferedReader(new StringReader(EndDateString));
while ((c = br.read()) != -1) {
output +=(char)c;
newword +=(char)c;
if(newword.equals(" ")|| newword.equals(".")){
if(OutputColumn+output.length() <= 29){
ret5.append(output);
OutputColumn =OutputColumn+output.length();
output = "";
}
else{
ret5.append("\r");
ret5.append(output);
OutputColumn = output.length();
output = "";
linecount ++;
}
}
newword = "";
}
}
catch (IOException e) {}
}
原则上,我知道打印字符串的代码可以正常工作,因为我有一段代码可以很好地打印当前日期。
任何帮助将不胜感激,谢谢!
I'm a newbie to this so be gentle!
I'm trying to parse a calendar object which I have incremented by 1 month to a string so that I can add it to a String Builder and eventually print it using a Bluetooth Printer.
Here's the code I'm currently trying to use;
else if
(Res.equals("&EXCLEND")){
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, 1);
SimpleDateFormat excluEnd = new SimpleDateFormat("DD-MM-YYYY-hh-mm");
String EndDateString ="";
// cal.DAY_OF_MONTH.toString() + "/" + cal.getDisplayName(Calendar.MONTH, cal.SHORT, cal.Locale.UK);
//Toast.makeText(getBaseContext(), EndDateString, Toast.LENGTH_LONG).show();
try {
BufferedReader br = new BufferedReader(new StringReader(EndDateString));
while ((c = br.read()) != -1) {
output +=(char)c;
newword +=(char)c;
if(newword.equals(" ")|| newword.equals(".")){
if(OutputColumn+output.length() <= 29){
ret5.append(output);
OutputColumn =OutputColumn+output.length();
output = "";
}
else{
ret5.append("\r");
ret5.append(output);
OutputColumn = output.length();
output = "";
linecount ++;
}
}
newword = "";
}
}
catch (IOException e) {}
}
In principal, I know that the code for the print string works as I have a piece of code to print the current date working fine.
Any help would be greatly appreciated, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想做的只是将日历对象打印为字符串,那么这样的事情应该可以工作
If all you are trying to do is print a calendar object as a string than something like this should work