我只想减去DateTime我尝试在Google上查找的1小时,我发现有一个名为minus的方法需要一份日期副本并在此处采取特定的持续时间:http://www.joda.org /joda-time/apidocs/org/joda/time/DateTime.html#minus(long)
但我不知道如何使用它,我无法在互联网上找到一个例子.
这是我的代码:
String string1 = (String) table_4.getValueAt(0, 1);
String string2= (String) table_4.getValueAt(0, 2);
DateTimeFormatter dtf = DateTimeFormat.forPattern("hh:mm a").withLocale(Locale.ENGLISH);
DateTime dateTime1 = dtf.parseDateTime(string1.toString());
DateTime dateTime2 = dtf.parseDateTime(string2.toString());
final String oldf = ("hh:mm a");
final String newf= ("hh.mm 0");
final String newf2= ("hh.mm a");
final String elapsedformat = ("hh.mm");
SimpleDateFormat format2 = new SimpleDateFormat(oldf);
SimpleDateFormat format2E = new SimpleDateFormat(newf);
Period timePeriod = new Period(dateTime1, dateTime2);
PeriodFormatter formatter = new PeriodFormatterBuilder()
.appendHours().appendSuffix(".")
.appendMinutes().appendSuffix("")
.toFormatter();
String elapsed …Run Code Online (Sandbox Code Playgroud) 我正在使用JDateChooser,我正在制作一个程序,输出所选日期之间的日期列表.例如:
date1= Jan 1, 2013 // Starting Date
date2= Jan 16,2013 // End Date
Run Code Online (Sandbox Code Playgroud)
然后它会输出
Jan 2, 2013...
Jan 3, 2013..
Jan 4, 2013..
Run Code Online (Sandbox Code Playgroud)
等等......直到它到达结束日期.
我已经完成了我的程序,一旦你单击JDatechooser它上面的日期将自动输出结束日期.(选定日期+ 15天=结束日期)
我下载JCalendar或JDateChooser在这里:http://www.toedter.com/en/jcalendar/
我有一个简短的等式:
double compute,computed2;
compute=getminutes/60;
Run Code Online (Sandbox Code Playgroud)
这里getminutes是int我想设置相当于compute有2位小数.0.00如何格式化2位小数的等效?
例:
compute=45/60 it should be 0.75
Run Code Online (Sandbox Code Playgroud)
这是我的工作:
DecimalFormat df2 = new DecimalFormat("00.00000");
double computed,computed2 = 00.000;
computed=60/getitbyminutes;
df2.format(computed);
computed2=computed-8;
df2.format(computed2);
System.out.printf("%1$.2f",computed);
System.out.println();
System.out.printf("%1$.2f",computed2);
Run Code Online (Sandbox Code Playgroud)
输出将如下:
1.00
7.00
Run Code Online (Sandbox Code Playgroud)