Sei sulla pagina 1di 10

TAREA N9

Clase 100
package fecha_tiempo;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
public class clase_100 {
/*se declara la variable de tipo fecha*/
private Date fecha;
/*se crea el constructor fecha donde se van a inicializar la variable fecha */
public clase_100(String xfecha) {
try {/*el try nose digita*/
/* se crea la varaibale de entrada*/
/*se crea el formato de fecha*/
DateFormat formatoingreso=new SimpleDateFormat("dd/MM/yy");
fecha=formatoingreso.parse(xfecha);/*en esta parte aparece que
debemos usar el tri cash
haciendo clic en el advertencia roja y hacer clic en block tri cash*/
} catch (ParseException ex) {
ex);

Logger.getLogger(clase_100.class.getName()).log(Level.SEVERE, null,
} }

public String getDia(){


int a;
String d=null;
a=fecha.getDay();
switch(a){
case 0 :d ="domingo"; break;
case 1 :d ="lunes"; break;

NOMBRE: GUSTAVO ALVARO HUAMANI


INGENIERIA DE SISTEMAS

case 2:d ="martes"; break;


case 3:d ="miercoles"; break;
case 4:d= "jueves";

break;

case 5:d ="viernes"; break;


case 6:d ="sabado"; break;
}
return d;
}
}

Formulario 100

NOMBRE: GUSTAVO ALVARO HUAMANI


INGENIERIA DE SISTEMAS

Clase 101
package fecha_tiempo;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Anio {

private Date Fecha1,Fecha2;


public void leer() {

try{
DateFormat formatoIngreso = new SimpleDateFormat("dd/MM/yy");
Fecha1=formatoIngreso.parse("01/01/2015");
Fecha2=formatoIngreso.parse("20/01/2013");
}
catch(ParseException ex){
Logger.getLogger(Vida.class.getName()).log(Level.SEVERE,null,ex);}
}

public long getDiasRestantes(){

long a,b,dt;
a=Fecha1.getTime();
b=Fecha2.getTime();

dt=(b-a)/(24 * 60 * 60 * 1000);

NOMBRE: GUSTAVO ALVARO HUAMANI


INGENIERIA DE SISTEMAS

return dt;
}}

Formulario 101
Anio clase101 =new Anio();
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
clase101.leer();
jLabel3.setText(String.valueOf(clase87.getDiasRestantes()));

Clase 102
NOMBRE: GUSTAVO ALVARO HUAMANI
INGENIERIA DE SISTEMAS

package guia9;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
public class clase88 {
private Date Fecha1,Fecha2;
public void leer() {

try{
DateFormat formatoIngreso = new SimpleDateFormat("dd/MM/yy");
Fecha1=formatoIngreso.parse("20/01/2015");
Fecha2=formatoIngreso.parse("31/12/2015");
}
catch(ParseException ex){
Logger.getLogger(Vida.class.getName()).log(Level.SEVERE,null,ex);}
}
public long getDiasRestantes(){
long a,b,dt;
a=Fecha1.getTime();
b=Fecha2.getTime();

dt=(b-a)/(24 * 60 * 60 * 1000);

return dt;
}
}

NOMBRE: GUSTAVO ALVARO HUAMANI


INGENIERIA DE SISTEMAS

Formulario 102

Clase 103
NOMBRE: GUSTAVO ALVARO HUAMANI
INGENIERIA DE SISTEMAS

Formulario 103

NOMBRE: GUSTAVO ALVARO HUAMANI


INGENIERIA DE SISTEMAS

Clase 104
package fecha_tiempo;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

public class clase_104 {


/*atributos de la clase*/
private Date fecha,nueva_fecha; /*para que ingrese le formato fecha*/
private int n=0;

/*constructor*/
public clase_104(String xfecha1, String xfecha2) {
try {
DateFormat guz=new SimpleDateFormat("dd/MM/yy");
fecha=guz.parse(xfecha1);

n=Integer.parseInt(xfecha2);
} catch (ParseException ex) {

NOMBRE: GUSTAVO ALVARO HUAMANI


INGENIERIA DE SISTEMAS

Logger.getLogger(clase_104.class.getName()).log(Level.SEVERE, null,
ex);
}

}/*metodo fecha nueva*/


public String fechaNueva(){
int mn;
mn=n*24*60*60*1000;
Date fechanueva=new Date(fecha.getTime()+mn);
DateFormat nf= DateFormat.getDateInstance();
return nf.format(fechanueva); }}

Formulario 104

NOMBRE: GUSTAVO ALVARO HUAMANI


INGENIERIA DE SISTEMAS

NOMBRE: GUSTAVO ALVARO HUAMANI


INGENIERIA DE SISTEMAS

Potrebbero piacerti anche